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

Ethan Furman ethan at stoneleaf.us
Wed Jun 26 10:04:00 CEST 2013


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

--
~Ethan~


More information about the Python-ideas mailing list