Necessity of ``pass''
skip at mojam.com
Tue Aug 24 13:31:46 EDT 1999
forcer> You didn't quote the example where i pointed out the real
forcer> problem with pass:
forcer> if foo:
forcer> # bar
forcer> # baz
forcer> E.g. if you're developing code and just commented out a (not yet
forcer> worked out branch) to work on a different part of the program.
forcer> Requireing pass here is unecessary.
A similar problem occurs in try/except statements. If you want temporarily
disable the try/except so you can see what exception is being raised, you
have to monkey around with the code a bit. I've gotten used to using "if
0:" and indenting the code another step with C-c > (I use Emacs):
The try/except issue is a little messier. You wind up with something like:
No language is perfect. I doubt that eliminating the requirement at least
one statement in a block is going to help much.
There are probably syntactic considerations as well. If you allow empty
blocks you probably introduce ambiguities in the language that you'd have to
Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/~skip/
847-971-7098 | Python: Programming the way Guido indented...
More information about the Python-list