calling superclass' method with list positional arg

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Fri Apr 13 06:12:19 EDT 2001


Fri, 13 Apr 2001 15:44:10 +0700, Steven Haryanto <steven at haryan.to> pisze:

>      def __init__(self, *items):
>          # do something else first...
> 
>          # then pass the items to superclass' constructor
>          args = list(items)
>          args.insert(0, self)
>          apply(Bag.__init__, args)

def __init__(self, *items):
    # do something else first...
    apply(Bag.__init__, (self,) + args)

Writing "tuple + tuple" concatenates tuples.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list