Need help with syntax on inheritance.

Calvin Spealman ironfroggy at gmail.com
Wed Oct 4 03:31:15 EDT 2006


On 3 Oct 2006 19:09:53 -0700, SpreadTooThin <bjobrien62 at gmail.com> wrote:
> If you are deriving a new class from another class,
> that you must (I assume) know the initializer of the other class.
>
> So in myClass
>
> import array
> class myClass(arrary.array):
>    def __init__(self, now here I need to put array's constructor
> parameters..., then mine):
>       array.array.__init__(self, typecode[, initializer])
>       self.mine = mine
>
> So I'm confused...
> array has a typecode parameter and an optional initiializer...
> So could you help me with the class construction here please?

If you need to take the same parameters as your super-class, and it
includes optional positional parameters, then simply call with
keywords to avoid the optional parameter:

   myClass(typecode, mine=something)

It has less to do with defining the parameters than calling the function.



More information about the Python-list mailing list