Garion,
SE treats the keyword
pass as an end-of-scope indicator, and decreases the indentation of the next statement line by 1 syntax indent value, which is 4 by default.
Because the pass statement[1] is used as a space holder to retain the scope when no other statements are present, it's typically not used unless that's the only statement in that scope. With that in mind, it does make sense that SE de-indents the next statement automatically.
So, by your examples:
if x == 7:
pass
somefunc()
This is expected, because of the presence of the pass statement. Try pasting the same line without the pass statement or before it. It should go
if x == 7:
somefunc()
and
if x == 7:
while x == 7:
pass
somefunc()
Are you sure this is what SE does? Because it's supposed to do the following:
if x == 7:
while x == 7:
pass
somefunc()
and my test confirms this to be the case. Anyway, again, try pasting the same line without the pass statement or before it and see if that makes any difference.
There are several other statements that are used in a similar manner, such as
continue,
break, and
return. These statements are all used as an end-of-scope indicator.
So, SE is in fact consistent with regard to this.
If you don't like this behavior, and want to hack at this,
you can remove or add keywords in
python_indent_col function. It's a Slick-C function, so you can get there by
fp python_indent_col
Scroll down a bit, and you'll see those keywords I listed above used inside a if statement.
Hope this sheds some light on this issue.
Kohei
[1]
http://docs.python.org/tut/node6.html#SECTION006500000000000000000