Traversing the properties of a Class

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Fri Jan 19 06:13:45 EST 2007


On Thu, 18 Jan 2007 18:03:41 +0000, Neil Cerutti wrote:

> On 2007-01-18, EdG <edquichan at yahoo.com> wrote:
>> For debugging purposes, I would like to traverse the class
>> listing out all the properties.
> 
> This is the first thing that came to mind.
> 
> def show_properties(cls):
>   for attr in dir(cls):
>     if isinstance(getattr(cls, attr), property):
>       print attr

Funny. The first thing that came to my mind was, "Thank you for sharing.
Did you have a question?"

*wink*



-- 
Steven.




More information about the Python-list mailing list