Python Class iteration howto !
Sindh
skodela at my-deja.com
Sat Sep 9 05:58:34 EDT 2000
Hi all
Suppose I have a class xyz with attributed name,age,sex,address etc. How
do I iterate the values.
eg:
class xyz:
name=''
age=0
sex='U'
address='U'
def iter(a):
for n in dir(a):
print a.n
but the above code says no attribute called a.n. How do I tell python to
substitute n for a attrib from list.
Thanks
sreekant
--
A man needs to sleep for 36 hours a day atleast.
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list