"JCM" <jo******************@myway.mathworks.com> wrote in message
news:bk**********@ginger.mathworks.com...
M-a-S <NO*****@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