NNTP Post a file

Alex Martelli aleaxit at yahoo.com
Fri May 4 12:14:54 EDT 2001


"Daniel" <Daniel.Kinnaer at Advalvas.be> wrote in message
news:svh5ftcs8rp5e36doo8ggdvo5o6mnfsgeh at 4ax.com...
    ...
> >> s.quit
> >
> >Note that you meant s.quit() here.
>
> I've checked the code and it had s.quit  (Python didn't complain about

Python doesn't complain about an expression-statement, one that
is just an expression -- it evaluates the expression and ignores
the result (if any).  But it only makes sense for you to use such
a statement when evaluating the expression has some side effect
(in the interactive interpreter, result of expression statements
are bound to a variable named '_' and displayed too -- but that
ONLY applies to interactive interpreter sessions).

Just:
    s.quit
gets the quit attribute of object s and does nothing with it.
No side effects, thus not a very useful expression statement.

On the other hand:
    s.quit()
CALLS the quit method of object s (and ignores the result).
Still an expression statement, but here there may be useful
side effects indeed:-).

This was not your problem in this case, but it's important to
be aware of this -- some other time, it might be the killer:-).


Alex






More information about the Python-list mailing list