Skip to content

Instantly share code, notes, and snippets.

@yeaske
Last active March 26, 2023 21:54
Show Gist options
  • Save yeaske/ba91afef59d32404a0ca5e95481eceef to your computer and use it in GitHub Desktop.
Save yeaske/ba91afef59d32404a0ca5e95481eceef to your computer and use it in GitHub Desktop.
__repr__ __str__
Provides an unambiguous string representation of an object. Provides a human-readable string representation of an object.
Mainly intended for developers and debugging purposes. Intended for end-users and display purposes.
If not explicitly defined, Python will use the default implementation. If not explicitly defined, Python will call the __repr__ method as a fallback.
Should ideally return a string that, when passed to eval(), would create an object with the same properties. Focuses on readability and displaying relevant information about the object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment