Yves Glodt wrote: > 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'
Is the following of any help to you? >>> class testclass: ... a = 'a' ... >>> dir(testclass) ['__doc__', '__module__', 'a'] >>> testclass.__dict__ {'a': 'a', '__module__': '__main__', '__doc__': None} >>> import inspect >>> inspect.classify_class_attrs(testclass) [('__doc__', 'data', <class __main__.testclass at 0x00AFBE70>, None), ('__module __', 'data', <class __main__.testclass at 0x00AFBE70>, '__main__'), ('a', 'data' , <class __main__.testclass at 0x00AFBE70>, 'a')] There are other methods in "inspect" which could help you. -Peter -- http://mail.python.org/mailman/listinfo/python-list