role of semilcolon
Andy Dustman
adustman at comstar.net
Mon Apr 12 19:06:08 EDT 1999
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
More information about the Python-list
mailing list