0

I was looking into a PR in GitHub and found the following python code that I could not understand.

def hash_pandas_object(
    obj,
    index: bool = True,
    encoding: str = "utf8",
    hash_key: str = _default_hash_key,
    hash_key: Optional[str] = _default_hash_key,
    categorize: bool = True,
)

Here are my questions:

(1) Are both hash_key are same or different and how they work?

(2) What Optional[str] means?

This is the link to the PR: https://github.com/TomAugspurger/pandas/commit/492c61385e25caf76377bf9819e21e7344e7a1bd

  • 3
    What you copied is the diff between two versions of the file. The first line containing `hash_key` has been removed (note the `-` sign and the red background color), and the second one added (note the `+` and green background). – Thierry Lathuille Jan 11 '20 at 14:04
  • Considering the explanation by @ThierryLathuille, I don't understand why this was marked as a duplicate of [How should I use the Optional type hint? ](https://stackoverflow.com/questions/51710037/how-should-i-use-the-optional-type-hint) – DarrylG Jan 11 '20 at 14:23
  • @DarrylG There where two parts in the question, the first was caused by the misunderstanding about the diff, I commented about that. The second was about the type hint, which is explained in the duplicate I linked to. – Thierry Lathuille Jan 11 '20 at 20:25
  • @ThierryLathuille--yes, I understood there were two parts with your comment answering the first part and the duplicate link answering the second. Perhaps I don't understand the meaning of duplicate (in general) since I occasionally encounter posts tagged as duplicates when the link is only partially related or provides an old answer which seems outdated. In this case, the duplicate link doesn't address the posters mean confusion which was looking at a diff file rather than code. So the poster would still be lost without your comment. – DarrylG Jan 11 '20 at 21:10

0 Answers0