Newbie - Recursive calls in class objects...

Alex the_brain at mit.edu
Mon Oct 2 21:06:28 EDT 2000


> I am trying to do something like pickling where I recursively call an
> object's method that prints out the object's instance variables.  I am
> looping thru the object's instance variables, printing each one.  I do this
> with the line:
> for t in self.__dict__.items():  (See listing below)
> I get into trouble if one of the instance variables ( t[0] )  is itself an
> object to be printed.  I can't seem to figure out how to test if the
> variable is an object.
> I've tried "isinstance(t[0], CElement)" which didn't work.
> I've tried "issubclass(t[0], CElement)" which didn't work, either.

Could you be a little more specific about what you want to do?  What
would you have liked the result of "isinstance(t[0], CElement)" to be? 

Alex.

-- 
Speak softly but carry a big carrot.




More information about the Python-list mailing list