iterate over class variables

Yves Glodt y.glodt at
Thu Nov 10 13:04:55 CET 2005

Hello list,

I need to iterate over a class and get all her variable names and 
values, e.g. considering this example:

class testclass:
	var1 = 'ab'
	var2 = 'cd'
	var3 = 'ef'

test = testclass()

Then I wanna do sonmething like this:

for name,value in test:
	print name
	print value

fails with of course with:
"TypeError: iteration over non-sequence"

How can I do that?


More information about the Python-list mailing list