Python n00b: promoting a derived class to base class?
I have an situation kind of like so: I have object b of class B, which is a derived from base class A. Is there a way I can cast or reassign object b so that it (or the new variable referring to it) it only has the interface of class A?
Obviously, polymorphism allows me to use object b anywhere as though it was simply a class A object. However, it would be a little more convenient if I could recast it as a class A object, so that I would never have to worry about unknowingly using a method from class B's interface.
In Java I would just assign object b to a Class A variable.
|