Multiple constructors (part 2)

Fredrik Lundh fredrik at effbot.org
Wed Jan 17 17:42:14 EST 2001


Daniel Klein wrote:
> The real kicker is that in one of the constructors, I need to
> check the __class__ of the object

no, you don't: use isinstance(obj, myClass) instead.

(if you can, consider using an informal interface in-
stead, and use hasattr() to check for distinguishing
methods or attributes)

Cheers /F





More information about the Python-list mailing list