[Python-ideas] Short form for keyword arguments and dicts

Joshua Landau joshua.landau.ws at gmail.com
Thu Jun 27 01:15:26 CEST 2013


On 26 June 2013 16:24, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 06/26/2013 07:46 AM, Joshua Landau wrote:
>>
>> On 26 June 2013 09:04, Ethan Furman <ethan at stoneleaf.us> wrote:
>>>
>>> A word doesn't stand out like a character does, plus this usage of pass
>>> is
>>> completely different from its normal usage.
>>>
>>> We're already used to interpreting '*' as a coin with two sides, let's
>>> stick
>>> with it:
>>>
>>>      def apply_map(map, target, *, frobble):  # '*' means frobble is
>>> keyword
>>> only
>>>         ...
>>>
>>> and later:
>>>
>>>      frobble = some_funny_stuff_here()
>>>      .
>>>      .
>>>      .
>>>      apply_map(map=kansas, target=toto, *, frobble) # '*' means frobble
>>> maps
>>> to keyword frobble
>>
>>
>> Whilst Greg Ewing has made me also much more sympathetic to this view,
>> I feel that:
>>
>> 1) This is nearly unreadable - it does not say what it does in the
>> slightest
>
>
> And the '*' and '**' in function defintions do?

Yes. The "*" symbol means "unpack" across a very large part of python,
and the lone "*" was a simple extension to what it already did. There
was no leap; I could've guessed what it did. It does not mean
"magically make an object know what its name is and then unpack both
of those -- implicitly over all of the following args!".

>> 2) It's added syntax - that's a high barrier. I'm not convinced it's
>> worth it yet.
>
> It is a high barrier; but this does add a bit of symmetry to the new
> '*'-meaning-keyword-only symbol.

I don't think it does - there's no symmetry as they have completely
different functions.

>> 3) It still feels like hackery; I might prefer something explicitly
>> hackery like this:
>
>
> You'll get used to it.  ;)

I bet you I won't :P.


More information about the Python-ideas mailing list