[Python-ideas] Short form for keyword arguments and dicts
Steven D'Aprano
steve at pearwood.info
Thu Jun 27 14:44:57 CEST 2013
On 27/06/13 13:01, Ron Adam wrote:
>
>
> On 06/26/2013 08:16 PM, Ethan Furman wrote:
>>
>> I don't know about you, but the first time I saw * and ** I had no idea
>> what they did and had to learn it.
>
> One of my fist thoughts when I first learned Python was that it would have made things clearer if they used two different symbols for pack and unpack.
>
> def foo(*args, **kwds):
> return bar(^args, ^^kwds)
>
> There isn't any issue for the computer having those the same, but as a human, the visual difference would have helped make it easier to learn.
I don't think it would be easier. I think that means you just have to learn two things instead of one, and have the added source of errors when you get them mixed up:
def foo(^args, ^^kwds):
return bar(*args, **kwds)
We don't seem to have problems with this:
items[x] = items[y]
rather than:
items{x} = items[y]
Or should it be the other way around?
--
Steven
More information about the Python-ideas
mailing list