On 02/20/2015 10:24 AM, Demian Brecht wrote: > I think that a decent rule around the usage of __str__ is that it should > be a string representation of the value, not of the object. Failing the > ability to logically coerce the value to a string, it should simply fall > back to repr(obj). There are two "stringy" methods for objects: __repr__ and __str__; if __str__ has not been defined __repr__ is automatically used. One of the motivating forces behind Enum is that often the name is more important (for humans) than the actual value, so __str__ is defined as being the Enum class name plus the Enum member name. The __repr__ has that as well as the underlying value (occasionally it's useful to know that, too ;) . -- ~Ethan~ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: <http://mail.python.org/pipermail/python-dev/attachments/20150220/eeff7a66/attachment.sig>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4