[Python-ideas] Enhancing vars()
Marco Buttu
marco.buttu at gmail.com
Tue Dec 13 04:29:38 EST 2016
On 13/12/2016 00:45, Steven D'Aprano wrote:
> In general, directly accessing dunders is a bit of a code smell. (I
> exclude writing dunder methods in your classes, of course.) There's
> usually a built-in or similar to do the job for you, e.g. instead of
> iterator.__next__() we should use next(iterator).
>
> One of the lesser-known ones is vars(obj), which should be used in place
> of obj.__dict__.
[...]
> Proposal: enhance vars() to return a proxy to the object namespace,
> regardless of whether said namespace is __dict__ itself, or a number of
> __slots__, or both.
+1. Would it be possible in the future (Py4?) to change the name `vars`
to a more meaningful name? Maybe `namespace`, or something more appropriate.
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: mbuttu at oa-cagliari.inaf.it
More information about the Python-ideas
mailing list