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

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


On 26 June 2013 16:43, Joao S. O. Bueno <jsbueno at python.org.br> wrote:
> On 24 June 2013 19:41, Steven D'Aprano <steve at pearwood.info> wrote:
>> On 25/06/13 03:58, Andrew McNabb wrote:
>>>
>>> I'm not even sure I like it, but many of the responses have denied the
>>> existence of the use case rather than criticizing the solution.
>>
>>
>> I haven't seen anyone deny that it is possible to write code like
>>
>> spam(ham=ham, eggs=eggs, toast=toast)
>>
>> What I've seen is people deny that it happens *often enough* to deserve
>> dedicated syntax to "fix" it. (I use scare quotes here because I don't
>> actually think that repeating the name that way is a problem that needs
>> fixing.)
>>
>
> Sorry for being silent for agreeing with the original proposal - but indeed -
> I think it does happen often enough to ask for some change - doubly so
> with stgin/template formatting calls (It is not fun to have to
> maintain 3rd party code
> doing format(**locals() ) , and just writting every used constant
> twice - and _then_ having to justify to others why that, awfull as it
> looks, is way better than using the **locals() call. (and yes, it
> _does_ happen)

Is it really that awful?

I mean, assuming you're sane and use .format_map.

But, as was said before, most of the time it doesn't make much sense
to do .format_map(locals()) as the variable you want should be part of
some more-naturally accessed namespace.

> , I think that there could possibly be something better than the
> proposed  syntax  -and we culd get to it - but as it is, it would eb
> good enough for me.


More information about the Python-ideas mailing list