Created
April 17, 2017 04:37
-
-
Save nasturtus/150ef873826b1578c21ebc65af784f27 to your computer and use it in GitHub Desktop.
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
# The goal of str() is readbility. | |
# The goal of repr() is to be unambiguous. | |
# The goal of type() is, well..to display the type. | |
# Reference: Corey Schafer https://www.youtube.com/watch?v=5cvM-crlDvg | |
from datetime import datetime | |
a = datetime.now() | |
print(str(a)) | |
print(repr(a)) # shows unambiguously it's a datetime | |
print() | |
b = str(a) | |
print(b) | |
print(repr(b)) # single quotes indicate unambiguously it's a string | |
print() | |
print(type(a)) | |
print(type(b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment