To get an instance that should be instance = eval(classname)() otherwise you have the class object, any fields set up by __init__ wont be listed by dir otherwise.
On Wed, 2009-05-27 at 12:36 +0100, Karl Stanley wrote: > This should work, but it won't win any marks for style: > > classname = "MyClass" > instance = eval(classname) > dir(instance) > > Karl > > Hi, > > If i have a class name as a string how can i get a list of the field > > names for the class. > > tks, > > PJ > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Python Ireland" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.ie/group/pythonireland?hl=en -~----------~----~----~----~------~----~------~--~---
