En Mon, 25 Jun 2007 15:10:25 -0300, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> escribió:
> In <[EMAIL PROTECTED]>, Jay Loden wrote: >> Neil Cerutti wrote: >>>> Is there a way to write a method that would list automatically >>>> all the variables defined as a property (say by printing their >>>> docstring and/ or their value), and only those variables? >>> >>> This is off the cuff. There's likely a better way. >>> >>> for k, v in MyClass.__dict__.iteritems(): >>> if isinstance(v, property): >>> print k, v.__doc__ >>> >> >> The only way I could get this to work was to change the way the >> properties were defined/initalized: > > That's because you iterate over the instance's `__dict__` and not over > the > *class* `__dict__` like Neil does. I would iterate over dir(MyClass) instead - only because I prefer to hide such implementation details. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list