I have a class that is provided to me by an external library. I have created a subclass of this class. I also have an instance of the original class.
I now want to t
In ojrac's answer, the break
breaks out of the for
-loop and doesn't test any more attributes. I think it makes more sense to just use the if
-statement to decide what to do with each attribute one at a time, and continue through the for
-loop over all attributes. Otherwise, I like ojrac's answer, as I too see assigning to __class__
as weird. (I'm a beginner with Python and as far as I remember this is my first post to StackOverFlow. Thanks for all the great information!!)
So I tried to implement that. I noticed that dir() doesn't list all the attributes. http://jedidjah.ch/code/2013/9/8/wrong_dir_function/ So I added 'class', 'doc', 'module' and 'init' to the list of things to add if they're not there already, (although they're probably all already there), and wondered whether there were more things dir misses. I also noticed that I was (potentially) assigning to 'class' after having said that was weird.