Re: Is there a better/simpler way to filter blank lines?
- From: Marc 'BlackJack' Rintsch <bj_666@xxxxxxx>
- Date: 5 Nov 2008 09:56:48 GMT
On Wed, 05 Nov 2008 14:39:36 +1100, Ben Finney wrote:
Marc 'BlackJack' Rintsch <bj_666@xxxxxxx> writes:
On Wed, 05 Nov 2008 13:18:27 +1100, Ben Finney wrote:
Marc 'BlackJack' Rintsch <bj_666@xxxxxxx> writes:
Your example shows only that they're important for grouping the
expression from surrounding syntax. As I said.
They are *not* important for making the expresison be a generator
expression in the first place. Parentheses are irrelevant for the
generator expression syntax.
Okay, technically correct but parenthesis belong to generator
expressions because they have to be there to separate them from
surrounding syntax with the exception when there are already enclosing
parentheses. So parenthesis are tied to generator expression syntax.
No, I think that's factually wrong *and* confusing.
>>> list(i + 7 for i in range(10))
[7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
Does this demonstrate that parentheses are “tied to” integer literal
syntax? No.
You can use integer literals without parenthesis, like the 7 above, but
you can't use generator expressions without them. They are always
there. In that way parenthesis are tied to generator expressions.
If I see the pattern ``f(x) for x in obj if c(x)`` I look if it is
enclosed in parenthesis or brackets to decide if it is a list
comprehension or a generator expression. That may not reflect the formal
grammar, but it is IMHO the easiest and pragmatic way to look at this as
a human programmer.
Ciao,
Marc 'BlackJack' Rintsch
.
- Follow-Ups:
- References:
- Is there a better/simpler way to filter blank lines?
- From: tmallen
- Re: Is there a better/simpler way to filter blank lines?
- From: bearophileHUGS
- Re: Is there a better/simpler way to filter blank lines?
- From: tmallen
- Re: Is there a better/simpler way to filter blank lines?
- From: Falcolas
- Re: Is there a better/simpler way to filter blank lines?
- From: Ben Finney
- Re: Is there a better/simpler way to filter blank lines?
- From: Marc 'BlackJack' Rintsch
- Re: Is there a better/simpler way to filter blank lines?
- From: Ben Finney
- Re: Is there a better/simpler way to filter blank lines?
- From: Marc 'BlackJack' Rintsch
- Re: Is there a better/simpler way to filter blank lines?
- From: Ben Finney
- Is there a better/simpler way to filter blank lines?
- Prev by Date: [JOB] Senior Python Engineer, NYC - Relo OK - 150-250k
- Next by Date: Re: Django or TurboGears or Pylons? for python web framework.
- Previous by thread: Re: Is there a better/simpler way to filter blank lines?
- Next by thread: Re: Is there a better/simpler way to filter blank lines?
- Index(es):
Relevant Pages
|