On Tue, 29 Apr 2008, Darryl Ross wrote:

I'm sure I've worked out how to to this in the past, but the syntax is escaping me right now.


class DooHicky(object):
   def __init__(self, arg1=None, arg2=None):
     pass

class Thingo(DooHicky):
   def __init__(self, value=None, *args, **kwargs):
       self.value = value
       super(Thingo, self).__init__(self, *args, **kwargs)


Basically, I want to pass in an argument to my "Thingo" class which does not get passed back to the parent constructor.

How about:

class DooHicky(object):
    def __init__(self, arg1=None, arg2=None):
        pass

class Thingo(DooHicky):
    def __init__(self, **kwargs):
        kwdict = kwargs
        self.value = kwdict['value']
        del kwdict['value']
        super(Thingo, self).__init__(**kwdict)

you would then need to always use keyword arguments, i.e.:
        Thingo(arg1=5, arg2="gday", value="fred")

is that ok for you ?

Chris Foote <[EMAIL PROTECTED]>
Inetd Pty Ltd T/A HostExpress
Web:   http://www.hostexpress.com.au
Blog:  http://www.hostexpress.com.au/drupal/chris
Phone: (08) 8410 4566
_______________________________________________
sapug mailing list
[email protected]
http://mail.python.org/mailman/listinfo/sapug

Reply via email to