Necessity of ``pass''
Phil Hunt
philh at vision25.demon.co.uk
Mon Aug 23 21:04:12 EDT 1999
In article <hhemgu41z7.fsf at forcix.roof.lan> forcer at mindless.com "forcer" writes:
> 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.
>
> 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)
>
> So it happens that Python has places where semantically nothing
> should be done, while syntactically it requires a statement.
>
> I consider this suboptimal.
>
> As a solution, one could allow the following:
> instead of
>
> if foo:
> pass
> bar
>
> 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.
>
> But...
> Most of the time, people write
>
> if foo:pass
> bar
>
> anyways so the "readability" does not suffer from leaving pass
> out.
>
> Also, the requirement for pass makes it impractical to comment
> out parts of an if expression, like in
>
> if foo:
> # baz
> # qux
> bar
>
> The new syntax would even allow a smooth transition, or
> coexistence of both versions. Pass can be retained to keep the
> possibility for a explicit do-nothing statment, while it's just
> not mandatory anymore.
>
> I'd like to see such a change in the Python language, so it'll be
> even cleaner than it was before.
>
> I hope my opinions and thoughts are of value to you,
> --forcer
<aol>I agree with all this</aol>
--
Phil Hunt....philh at vision25.demon.co.uk
More information about the Python-list
mailing list