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

Alex Light scialexlight at gmail.com
Wed Jul 21 12:35:42 CEST 2010


nick coughlan wrote:
> 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.
@Chris Robert
sorry what i meant in saying that
" a_variable = an_expression" is that, it seems to me, at least, the only
allowed
statements are ones where a variable is set to a value, which includes
"class" and "def"
(and some control flow, if, else etc.)

also in the first post:
Sergio Davis wrote:
>I'm considering the following extension to Python's grammar: adding the
'where' keyword, which would work as follows:
>
>where_expr : expr 'where' NAME '=' expr

On Tue, Jul 20, 2010 at 10:56 PM, Chris Rebert <pyideas at rebertia.com> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100721/25aac99a/attachment.html>


More information about the Python-ideas mailing list