PEP 289: Generator Expressions (please comment)

Alex Martelli aleax at aleax.it
Tue Oct 28 08:06:11 EST 2003


Daniel Dittmar wrote:

> Alex Martelli wrote:
>>> counter proposal:
>>> g[(p.score, p.name) for p in players ]
>>
>> Looks like it's indexing g.
>>
>>> This works similar to r'\' for raw strings and u'x' for unicode
>>> strings.
>>
>> Nope, it's ambiguous, while <single letter> adjacent to '...' isn't.
> 
> Although I admit my proposal is flawed, the principle behind is is sound,
> namely that syntax constructs should be recognisable at the start.

Avoiding lookahead is a good principle, but not an absolute.

For example, when I see a literal that starts with the characters:

    1233445

I do NOT start grumbling that, since it violates the Dittmar Principle,
I'm desperate by not yet knowing after reading the first few characters
whether it's going to be an integer literal, such as

    123344567

or a float literal, such as

    1233445.67

Your "should" is just too weak to make this notation other than
perfectly fine.  A language designed strictly by your principle, thus
forcing initial stropping of digit sequences to distinguish e.g.
integer literals from float ones, would be a syntax disaster.


>>> p[$*-=%/sd/!] allows to embed perl code
>>
>> If you want perl, you know where to find it.
> 
> See how difficult it is even for you to recognize something if it isn't
> introduced by the proper markers, in this case <sarkasm>?

"Introduced" matters not a whit (just like the fact that, in English,
"sarcasm" is spelled with a c and not with a k).  If you had chosen to
indicate your dubious sarcasm (against your own proposal?!) by a
trailing parenthetical such as "(just kidding)" I would not have
wasted the time to respond.  Don't take the _complete_ lack of any
clarifying denotation (which is definitely a stupid choice) obscuring
the message, as any proof that the clarifying denotation must be
BEFORE rather than AFTER -- it just doesn't follow.  As your proposal
DOES look distinctly perlish (cfr q/foo/ vs qq/foo/ etc), it's quite
reasonable to form the working hypothesis that you LIKE perl syntax,
rather than being engaged in sarcasm against your own proposals (which
is a form of split personality one rarely comes upon).


Alex





More information about the Python-list mailing list