Traversing the properties of a Class

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Thu Jan 18 15:36:14 EST 2007


EdG a écrit :
> I'm using Python version 2.4 and I created a class with some properties
> like:
> 
> def GetCallAmount(self):
>         return somedata

<mode="pep08">
The recommended naming convention is all_lower,ie:
def get_call_amount(self):
</mode>

And FWIW, there are idioms to avoid polluting the class namespace, like:

class Account(object):
     @apply
     def amount():
        def fget(self):
            return something
        def fset(self, value):
            do_something_with(value)
        return property(**locals())

> For debugging purposes, I would like to traverse the class listing out
> all the properties.

cf Neil's answer.




More information about the Python-list mailing list