[Python-ideas] Short form for keyword arguments and dicts
Ethan Furman
ethan at stoneleaf.us
Wed Jun 26 01:32:13 CEST 2013
On 06/25/2013 02:43 AM, Andrew Barnert wrote:
> From: Greg Ewing:
>
>> I dispute that they're different names. In the use cases
>> I have in mind, it's no accident that the two names are
>> spelled the same, because conceptually they represent the
>> very same thing.
>
> I've already asked Anders this, but let me ask you as well: What are the use cases you have in mind?
>
> As I see it, there are three cases (barring coincidences, which are obviously irrelevant) where this syntax could make a difference:
>
> 1. dict constructor
> 2. str.format
> 3. forwarding functions (like my example with get_appdir_url)
For me it's mostly #3, and the cases where I use it passing positionally is not an option because the arguments are
keyword only.
If something like this comes to pass, I would argue for the syntax that MRAB suggested:
some_func(pos1, pos2, =, keyword, keyword, keyword)
or possibly:
some_func(pos1, pos2, *, keyword, keyword, keyword)
to mirror the function definition.
--
~Ethan~
More information about the Python-ideas
mailing list