469,643 Members | 1,670 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Colons, indentation and reformatting.

i was just perusing a Wikipedia entry on the "off side rule" at
http://en.wikipedia.org/wiki/Off-side_rule .
It says that the colon in Python is purely for readability, and cites
our FAQ entry
http://www.python.org/doc/faq/genera...ass-statements
Jan 9 '07 #1
2 1084
Paddy wrote:
Thinking about it a little, it seems that a colon followed by
non-indented code that has just been pasted in could also be used by a
Python-aware editor as a flag to re-indent the pasted code.

How would it reindent this code?

if foo:
print "Foo!"
if bar:
print "Bar!"

Like this?

if foo:
print "Foo!"
if bar:
print "Bar!"

Or like this?

if foo:
print "Foo!"
if bar:
print "Bar!"
Jan 9 '07 #2
On 2007-01-09, Leif K-Brooks <eu*****@ecritters.bizwrote:
Paddy wrote:
>Thinking about it a little, it seems that a colon followed by
non-indented code that has just been pasted in could also be
used by a Python-aware editor as a flag to re-indent the
pasted code.

How would it reindent this code?

if foo:
print "Foo!"
if bar:
print "Bar!"

Like this?

if foo:
print "Foo!"
if bar:
print "Bar!"

Or like this?

if foo:
print "Foo!"
if bar:
print "Bar!"
That's the key issue. The colon gives the editor an easy clue
where a block starts, but the there's no simply way to determine
where the block is supposed to end.

--
Neil Cerutti
Remember in prayer the many who are sick of our church and community. --Church
Bulletin Blooper
Jan 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Draz | last post: by
3 posts views Thread by Chris Lane | last post: by
7 posts views Thread by Lloyd Sheen | last post: by
6 posts views Thread by Abhishek Srivastava | last post: by
9 posts views Thread by Paddy | last post: by
6 posts views Thread by Grant Robertson | last post: by
19 posts views Thread by Eric S. Johansson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.