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

Ethan Furman ethan at stoneleaf.us
Wed Jun 26 17:24:05 CEST 2013


On 06/26/2013 07:46 AM, Joshua Landau wrote:
> On 26 June 2013 09:04, Ethan Furman <ethan at stoneleaf.us> wrote:
>> On 06/26/2013 12:48 AM, Greg Ewing wrote:
>>>
>>> Ron Adam wrote:
>>>>
>>>> And I don't like the '=' with nothing on the right.
>>>
>>>
>>> Expanding on the suggestion someone made of having a
>>> single marker of some kind in the argument list, I
>>> came up with this:
>>>
>>>       def __init__(self, text, font = system_font, style = 'plain'):
>>>          default_size = calc_button_size(text, font, style)
>>>          Widget.__init__(self, size = default_size, pass font, style)
>>
>>
>> I don't care for it.
>>
>> 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?


> 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.


> 3) It still feels like hackery; I might prefer something explicitly
> hackery like this:

You'll get used to it.  ;)

--
~Ethan~


More information about the Python-ideas mailing list