Luke Paireepinart wrote:

> You mean that the dictionary _definition_ ignores whitespace between 
> elements?
> 
> That's not a feature of dictionaries, but of the comma.
> You can easily do the following:
> x = [1, 2,
>        3, 4]
> if you want.
> Same with tuples and various other things.
> Python just realizes that if it doesn't see a closing brace/bracket, but 
> sees a comma, that more will probably be coming on the next line.

That's not quite right. It is the open brace/bracket/parenthesis that 
tells Python to continue the line; the comma is not part of it. For 
example, this works:
In [17]: a=1,2,3,4

but inserting a newline, even after a comma, breaks it into two statements:
In [24]: a=1,2,
In [25]: 3,4
Out[25]: (3, 4)
In [26]: a
Out[26]: (1, 2)

OTOH, if there is an open bracket, the comma can come on the next line:

In [21]: a=[1
    ....: ,2,3,4]
In [22]: a
Out[22]: [1, 2, 3, 4]

Kent
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to