Necessity of ``pass''

William Tanksley wtanksle at dolphin.openprojects.net
Tue Aug 24 04:18:53 CEST 1999


On 23 Aug 1999 23:32:44 +0200, forcer wrote:
>Hi there.

>Lately, i've been thinking about Python. While it is an
>exceptionally clean language, it has one very obvious wart:
>The ``pass'' statement.

I disagree that 'pass' is an obvious wart.  I think it's very nice.

>To quote the reference manual:

>   pass is a null operation -- when it is executed, nothing
>   happens. It is useful as a placeholder when a statement is
>   required syntactically, but no code needs to be executed, for
>   example:

>   def f(arg): pass    # a function that does nothing (yet)

>one could write

>	if foo:
>	bar

>Syntactically this does not introduce any ambiguity. The only
>problem i see is that the "pass" version is more readable.

Precisely.  You're suggesting a change with the sole purpose of reducing
redundancy.  The problem is that humans _need_ redundancy.  Not only does
redundancy help us to read the code, it also helps the computer to find
our errors.

Another example of redundancy in Python -- and one with just as much
chance of being changed -- is the ':' symbol.  Take a look at the following:

if foo: pass
bar

if foo pass
bar

if foo
  pass
bar

As you see, the colons aren't necessary.  They're only there as a
convenience to the programmers and readers.

>       --forcer

-- 
-William "Billy" Tanksley




More information about the Python-list mailing list