[Python-ideas] automation of __repr__/__str__ for all the common simple cases

Nathan Rice nathan.alexander.rice at gmail.com
Thu Feb 16 15:55:27 CET 2012


> instead of the ReprMixin, how about a descriptor
>
> the Api would change to something like
>
> class User(object):
>  __repr__ = FormatRepr('<User {name!r}')
>
> its less concise, but actually more straightforward and better decoupled
> (thanks for hinting at the strong coupling in the class hierarchy)
>
> and ArgRepr and KwargRepr could be added in a similar fashion

+1 for not using inheritance (which honestly creates about as many
problems as it solves)...

Having some of the common use cases like this as descriptors that
could be imported and used directly would be an improvement on the
current interface of the lib IMHO.


Nathan



More information about the Python-ideas mailing list