On Wed, Mar 9, 2011 at 9:20 AM, Ethan Furman <et...@stoneleaf.us> wrote: > Just make sure and call the parent's constructor, either with > > class NewClass(BaseClass): > def __init__(self, ....): > BaseClass.__init__(self, other_params) > > or > > class NewClass(BaseClass): > def __init__(self, ....): > super(NewClass, self).__init__(....)
In Python3 this is even easier (for the simplest case): >>> class Base: ... def __init__(self, x): ... print("Hello %s" % x) ... >>> class ExtendedBase(Base): ... def __init__(self, x, y): ... super().__init__(x) ... print("Hello %s" % y) ... >>> x = ExtendedBase("foo", "bar") Hello foo Hello bar >>> cheers James -- -- James Mills -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo/python-list