[sapug] TypeError: __init__() got multiple values for keyword argument 'value'
spam at afoyi.com
Tue Apr 29 07:01:45 CEST 2008
Tim Wegener wrote:
> # If you expect the value argument to be unspecified more often than not:
> class Thingo(DooHicky):
> def __init__(self, *args, **kwargs):
> self.value = kwargs.get('value')
> if self.value is not None:
> del kwargs['value']
> super(Thingo, self).__init__(self, *args, **kwargs)
This is pretty much exactly what I came up with.
> You might also want to consider avoiding the use of inheritance. I
> can't really comment on whether it is desirable to use inheritance
> here, given the supplied information. Personally I try to avoid
> inheritance unless it is a really nice fit for the situation.
In this particular instance, I do actually need the inheritance. I'm
subclassing a django.newforms.Form.
Daryl Tester wrote:
> Python version? Under 2.5.1:
Hmm, good point, I didn't check that. I was testing under 2.4.3 which is
on my CentOS 5.1 server. On my Ubuntu laptop, which has 2.5.1, my sample
code works as I was expecting.
More information about the sapug