Last active
March 4, 2024 18:02
-
-
Save HundredVisionsGuy/340f7a855ed637aaed1f2c088dc42438 to your computer and use it in GitHub Desktop.
Sample of docstrings and type hinting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
datetime_typehints | |
by a now deleted user from Reddit | |
Example of docstrings and type annotations (type hints) in code. | |
Reddit article link: | |
https://www.reddit.com/r/learnpython/comments/qcbz67/type_hinting_for_datetimedate_and_datetimetime/ | |
""" | |
import datetime | |
def unnecessary_function(date_string: str) -> datetime.date: | |
"""returns a date object in isoformat""" | |
return datetime.date.fromisoformat(date_string) | |
if __name__ == '__main__': | |
print(unnecessary_function("2022-02-02")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment