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

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


On 06/26/2013 07:59 AM, Ron Adam wrote:
>
>
> On 06/26/2013 02: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)
>
>
> Using the '*' in the call sites as suggested earlier because of it's consistency with function definitions is probably a
> better choice.
>
> In the above example, would the '*' (or pass) be in the same place as the it is in the function definition?
>
>       Widget.__init__(self, *, size=default_size, font, style)
>
> Or:
>
>       Widget.__init__(self, size=default_size, *, font, style)
>
>
> I think it should, because then there would be a clearer separation between what are positional and keyword arguments
> throughout a program.

Not at all.  Just like we can use keyword arguments even when the '*'-keyword-only symbol has not been used, we should 
be able to use the '*'-variable-name-is-keyword whenever we have keyword arguments available -- which is most of the time.

--
~Ethan~


More information about the Python-ideas mailing list