[Python-ideas] Positional only arguments
Aaron Brady
castironpi at comcast.net
Tue May 22 00:59:51 CEST 2007
> -----Original Message-----
> From: python-ideas-bounces at python.org [mailto:python-ideas-
> bounces at python.org] On Behalf Of Steven Bethard
> Sent: Sunday, May 20, 2007 10:24 AM
>
> I've also noticed that the current @posonly decorator won't solve the
> dict() and dict.update() problem::
>
> >>> @posonly(2)
> ... def update(self, container=None, **kwargs):
> ... print self, container, kwargs
> ...
> >>> update(self=1, other=2)
Question on it, the example. Is this not a feature of all UserDict
subclasses? Yet we have that anyway.
>>> from UserDict import *
>>> class C(UserDict):
... pass
...
>>> c= C( a=1, b=2 )
>>> print c
{'a': 1, 'b': 2}
>>> c.update( self=3 )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: update() got multiple values for keyword argument 'self'
Where are you -def-ing update?
More information about the Python-ideas
mailing list