Python Class iteration howto !

Neil Hodgson neilh at scintilla.org
Sat Sep 9 06:28:46 EDT 2000


Sindh wrote:
> Suppose I have a class xyz with attributed name,age,sex,address etc. How
> do I iterate the values.
> ...
> def iter(a):
> for n in dir(a):
> print a.n

def iter(a):
 for n in dir(a):
  print a.__dict__[n]

   Neil






More information about the Python-list mailing list