Coercing classes

Eckhard Pfluegel Eckhard at pfluegel.fsnet.co.uk
Fri Jun 23 19:38:40 EDT 2000


My question is the following: imagine you have two classes A and B where
B is derived from A (B is a subclass of A). The object a is assigned to
an instance of class A:

a = A()

Under which conditions on the structure of class B is it possible in
Python to convert 'a' to an instance of B? In my application, B would
only have one additional method defined and no additional attributes
(than defined in A), so that a conversion would make sense.
Are there any built-in functions for that purpose??

Eckhard





More information about the Python-list mailing list