[Python-Dev] Very Strange Argument Handling Behavior

Vinay Sajip vinay_sajip at yahoo.co.uk
Sat Apr 17 14:41:03 CEST 2010


Steve Holden <steve <at> holdenweb.com> writes:

> I'm sure we wouldn't want to go so far as to inhibit this. (Py 3.1)
> 
> >>> def f(**kwargs):
> ...   kwargs[1] = "dummy"
> ...   print(kwargs)
> ...
> >>> f(this="Guido", that="Raymond", the_other="Steve")
> {'this': 'Guido', 1: 'dummy', 'the_other': 'Steve', 'that': 'Raymond'}

I think that according to the proposal, the above snippet would be OK, but

def f(**kwargs):
    kwargs[1] = 'dummy'
    g(**kwargs)

would fail at the call of g.

Regards,

Vinay Sajip



More information about the Python-Dev mailing list