why pass statement?
Terry Reedy
tjreedy at udel.edu
Wed Sep 17 10:17:56 EDT 2003
"JCM" <joshway_without_spam at myway.mathworks.com> wrote in message
news:bk9oel$4mu$1 at ginger.mathworks.com...
> M-a-S <NO-MAIL at hotmail.com> wrote:
> > Why is there the pass statement? I think, the expression statement
would be enough:
>
> > class C:
> > None
>
> > while True:
> > None
>
> Because emacs python-mode knows to dedent the next line after a pass
:)
Nice.
pass is the guaranteed-to-do-nothing identity statement (function
operating on the interpreter state). def f(): pass generates a
*miminal* function object with a *minimal* code object. This is at
least potentially useful for testing or investigating the
implementation. The alternative of an expression statement adds code
to the code body. The alternative of a doc string generates a string
object attached somewhere to the no-longer-minimal function or code
object. Indeed, the way to test the effect of either alternative is
to start with the minimum and then define f2 and look for the
difference -- as one of the earlier posters in this thread did do
(using dis module to 'look') for the None expression.
Terry J. Reedy
More information about the Python-list
mailing list