[Python-Dev] accumulator display syntax

Skip Montanaro skip at pobox.com
Fri Oct 17 12:38:07 EDT 2003

    >> I agree.  Any expression bracketed by '[' and ']', no matter how many
    >> other clues to the ultimate result it might contain, ought to result
    >> in a list as far as I'm concerned.

    Alex> Hmmm, how is, e.g.
    Alex>     foo[x*x for x in bar]
    Alex> any more an "expression bracketed by [ and ]" than, say,
    Alex>     foo = {'wot': 'tow'}
    Alex>     foo['wot']
    Alex> ...?  

When I said "expression bracketed by '[' and ']' I agree I was thinking of
list construction sorts of things like:

    foo = ['wot']

not indexing sorts of things like:


I'm not in a mood to try and explain anything in more precise terms this
morning (for other reasons, it's been a piss poor day so far) and must trust
your ability to infer my meaning.  I have no idea at this point how to

    foo[x*x for x in bar]

That looks like a syntax error to me.  You have a probably identifier
followed by a list comprehension.

Here's a slightly more precise term: If a '['...']' construct exists in
context where a list constructor would be legal today, it ought to evaluate
to a list, not to something else.

    Alex> ... just as e.g. foo[ 'va':23:2j, {'zip':'zop'}:45:(3,4) ] ...

I have absolutely no idea how to interpret this.  Is this existing or
proposed Python syntax?


More information about the Python-Dev mailing list