[Python-ideas] 'where' statement in Python?

Andrey Popp 8mayday at gmail.com
Tue Jul 20 16:57:15 CEST 2010


Hello,

PEP-3150 is awesome, just a small addition — why not to allow
one-liners `where`s:

    a = (b, b) where b = 43

And that also make sense for generator/list/set/dict comprehensions:

    mylist = [y for y in another_list if y < 5 where y = f(x)]

On Tue, Jul 20, 2010 at 5:27 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Tue, Jul 20, 2010 at 3:29 PM, Stephen J. Turnbull <stephen at xemacs.org> wrote:
>> We just had a long thread about this.
>>
>> http://mail.python.org/pipermail/python-ideas/2010-June/007476.html
>>
>> The sentiment was about -0 to -0.5 on the idea in general, although a
>> couple of people with experience in implementing Python syntax
>> expressed sympathy for it.
>
> For the record, I am personally +1 on the idea (otherwise I wouldn't
> have put so much thought into it over the years). It's just a *lot*
> harder to define complete and consistent semantics for the concept
> than people often realise.
>
> However, having the question come up twice within the last month
> finally inspired me to write the current status of the topic down in a
> deferred PEP: http://www.python.org/dev/peps/pep-3150/
>
> Cheers,
> Nick.
>
> --
> Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 
Andrey Popp

phone: +7 911 740 24 91
e-mail: 8mayday at gmail.com



More information about the Python-ideas mailing list