Tim Chase a écrit : >>>>> class Foo(object): >> >> ... pass >> ... >> >>>>> b = Foo >>>>> b.__name__ >> >> 'Foo' > > > While this is surely true, would somebody explain why I had such trouble > finding this?
Mmm... Documentation needs update ? > >>>> help(dir) > > Help on built-in function dir in module __builtin__: > > continuing from your example... > > >>> dir(b) > ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', > '__hash__', '__init__', '__module__', '__new__', '__reduce__', > '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__'] > >>> '__name__' in dir(b) > False > > '__name__' *really is* a method s/method/attribute/ > of b as shown by your example lines, and > can be successfully called. However, it *doesn't* show up when asked > for via dir(b). Grumble. Yes, as mentionned in the doc, dir() doesn't list *all* names in a namespace. DOn't ask me why nor how it chooses which ones it rejects, I wonder too. > Is there a dir_and_i_really_mean_everything() function? Perhaps in the inspect module... -- http://mail.python.org/mailman/listinfo/python-list