43 lines
1.2 KiB
Plaintext
43 lines
1.2 KiB
Plaintext
From: adustman at comstar.net (Andy Dustman)
|
|
Date: Mon, 12 Apr 1999 23:06:08 GMT
|
|
Subject: role of semilcolon
|
|
In-Reply-To: <slrn7h4q72.mou.rasumner@bach.wisdom.weizmann.ac.il>
|
|
References: <slrn7h4q72.mou.rasumner@bach.wisdom.weizmann.ac.il>
|
|
Message-ID: <Pine.LNX.4.10.9904121900560.12527-100000@kenny.comstar.net>
|
|
X-UID: 149
|
|
|
|
On 12 Apr 1999, Reuben Sumner wrote:
|
|
|
|
> In the python interpreter doing 'a=1;b=2;b=3' does what I would
|
|
> expect, three seperate assignments. However ; doesn't seem to appear
|
|
> in the language reference except in the list of delimeters. Is the
|
|
> above example formally valid python?
|
|
|
|
Semicolon is a statement separator. So is the end of line unless you have
|
|
open parentheses, brackets, braces, or triple-quotes. So:
|
|
|
|
a=1;b=2;b=3
|
|
|
|
is the same as:
|
|
|
|
a=1
|
|
b=2
|
|
b=3
|
|
|
|
But a Pythonism you may want to adapt is:
|
|
|
|
a,b,c = 1,2,3
|
|
|
|
In practice, semicolon is rarely used in Python, since the end of line
|
|
separates statements just as well with one less byte (none vs. one :), and
|
|
multiple assignments can be done as above.
|
|
|
|
--
|
|
andy dustman | programmer/analyst | comstar communications corporation
|
|
telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d
|
|
|
|
|
|
|
|
|
|
|