looping over a class attribute

Aahz aahz at pythoncraft.com
Fri Mar 12 17:35:17 EST 2004


In article <b82e5469.0403121359.f099aa8 at posting.google.com>,
biner <biner.sebastien at ouranos.ca> wrote:
>
>I would like to be able to make a loop like this 
>>>> dir(x)
>['__doc__', '__module__', 'val1', 'val2']
>>>> for i in dir(x) : print x.i

print getattr(x, i)
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"usenet imitates usenet"  --Darkhawk



More information about the Python-list mailing list