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

Chris Rebert pyideas at rebertia.com
Wed Jul 21 04:56:57 CEST 2010


On Tue, Jul 20, 2010 at 7:50 PM, Alex Light <scialexlight at gmail.com> wrote:
> Carl M. johnson wrote:
>>2.) What happens in this case:
>>
>>x = y given:
>>    return "???"
>>
>>Do we just disallow return inside a given? If so, how would the parser
>>know to allow you to do a def inside a given?
> i think so because unless i am misunderstanding something the only allowed
> expressions
> in a 'given' block would be of the type:
> a_variable = an_expression

Incorrect. Yes, you are misunderstanding:

On Tue, Jul 20, 2010 at 3:13 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Wed, Jul 21, 2010 at 6:13 AM, Alex Light <scialexlight at gmail.com> wrote:
>> i would use as because this whole where clause acts very similarly to a
>> context manager in that it sets a variable to a value for a small block
>
> No, the idea is for the indented suite to be a perfectly normal suite
> of Python code. We want to be able to define functions, classes, etc
> in there. Inventing a new mini-language specifically for these clauses
> would be a bad idea (and make them unnecessarily hard to understand)
<snip>
> Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

Did you not read Nick's reply yet when you wrote this, or...?

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-ideas mailing list