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
On 12/12/2016 6:45 PM, 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(iterato
On 12/12/2016 03:45 PM, Steven D'Aprano wrote:
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
--
~Ethan~
___
Python-ideas mailing lis
On Mon, Dec 12, 2016 at 6:45 PM, Steven D'Aprano
wrote:
> 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.
>
How do you propose dealing with classes defined in C? Their objects don
I'm +1. This bites me far too often.
> in the past developers
were encouraged to put only "useful" attributes in __dir__.
Good. If I'm getting vars() I really only want the useful ones. If I need
interesting/secret ones then I'll getattr for them.
Cheers,
Steve
Top-posted from my Windows Phone