[IronPython] Using blocks separators instead of indentation
Curt Hagenlocher
curt at hagenlocher.org
Mon Aug 13 23:39:00 CEST 2007
On 8/13/07, Ori <oorrii at gmail.com> wrote:
>
>
> Thanks but I did not ask if it is ugly or not. I just need it.
> Is there a way to do it?
In my email, I also gave two examples of legal Python code with more than
one statement per line.
In general, you can put any number of commands on the same line using a
semi-colon as separator. That means that the following is legal Python:
print 'hello'; print 'goodbye'; print 'up'; print down
However, conditional and looping constructs that contain a colon -- that is,
"if", "for", "while", etc. -- are limited to one per line, and the statement
ending in a colon must be the first one on the line. That is, the first of
these lines is legal Python and the second and third are not.
if 1: print 'goodbye'; print 'hello'
print 'hello'; if 1: print 'goodbye'
if 1: print 'goodbye'; else: print 'hello'
--
Curt Hagenlocher
curt at hagenlocher.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070813/af1781e6/attachment.html>
More information about the Ironpython-users
mailing list