[Python-Dev] introducing dir? (original) (raw)

tomer filiba tomerfiliba at gmail.com
Thu Jul 6 19:22:51 CEST 2006


i'd guess this has been brought up before, but i'm not aware of it.

anyway -- by what i've gathered, today's dir() "collects" the attributes of the object from dict, methods, members, and ultimately class. also, if i understood correctly, methods and members are deprecated. moreover, they are sequence objects, rather than callbale functions. that means my code can't

my suggestion is simple -- replace this mechanism with a dir - a special method that returns the list of attributes of the object.

rationale:

and the reason for bringing this up in the first place -- allowing proxy objects to show the attributes of the internal object. for example, in rpyc, i had to override builtin.dir to achieve this functionallity, which is of course not the optimal sollution.

implementation: very straight forward and similar to the rest of the special methods:

the ultimate object type would grow a default dir method that uses the same modus operandi as today's dir, which deriving classes could override to provide custom listings. therefore, i don't expect any backward-compatibility issues.

aye or nay?

-tomer



More information about the Python-Dev mailing list