Requiring arguments to be passed as keyword arguments

Evan Simpson evan at tokenexchange.com
Thu Oct 7 12:16:19 EDT 1999


Greg Ewing <greg.ewing at compaq.com> wrote in message
news:37FCAF01.99B03CA3 at compaq.com...
> Let's approach this in a more general way. First,
> introduce dictionary unpacking:
>
>    (foo, bar, baz) = dict

Nice idea, but isn't this syntax dangerously similar to tuple unpacking?
One 'natural' interpretation of this as dictionary unpacking would be:

foo = dict[0]; bar = dict[1]; baz = dict[2]

which would semantically parallel tuple unpacking, but wouldn't do what you
want.  Besides, what about unpacking keys which aren't valid identifiers?
How about:

{ foo, (1, 3.5): bar, 'x. x. x.': baz} = dict

meaning

foo = dict['foo']; bar = dict[(1, 3.5)]; baz = dict['x. x. x.']

In other words, the same as yours except with {}s and the ability to specify
key:var combinations.






More information about the Python-list mailing list