Skip to content

Instantly share code, notes, and snippets.

@HundredVisionsGuy
Last active March 4, 2024 18:02
Show Gist options
  • Save HundredVisionsGuy/340f7a855ed637aaed1f2c088dc42438 to your computer and use it in GitHub Desktop.
Save HundredVisionsGuy/340f7a855ed637aaed1f2c088dc42438 to your computer and use it in GitHub Desktop.
Sample of docstrings and type hinting
"""
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