FAQ

Greg Ewing <greg.ewing at compaq.com> writes:

"Magnus L. Hetland" wrote:
[(i, s) for i in nums and s in strs]
That would be ambiguous, because it could be parsed as

[(i, s) for i in (nums and s in strs)]
Which, in the case that nums is not an empty list, would be

[(i, s) for i in nums]

IC. Oh, well... But what about:

[(i, s) for i in nums, and s in strs]

This is still grammatically correct English, AFAIK... And the ", and"
constellation does not have another valid interpretation, does it?

(Though it might not be really pretty...)
It *might* be feasible to use

[(i, s) for i in nums and for s in strs]
Nice. Much less confusing than just using the *for* directly.

(Of course, any mechanisms of parallel iteration might be used here if
they appear... Like [(i, s) for i, s in nums, strs] or something)
If I get a spare moment or two one day I'll try this
and see whether the parser chokes. (Python's parser
is a bit strange - it's hard to predict what it can
handle and what it can't.) Good :)
Greg
--

Magnus Echelon jamming noise:
Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism
Hetland Special Forces Delta Force AK47 Hillary Clinton

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 4 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedDec 13, '99 at 12:39a
activeDec 13, '99 at 10:29p
posts4
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase