Syntax Error

chris at chris at
Sat Feb 3 17:34:26 EST 2001

On Sat, 3 Feb 2001 kwasi007uk at wrote:

> Using e.g. poplib, m=poplib.POP3 ...
> I typed in error m.quit.
> It should have been m.quit().
> Why doesn't Python give me an error message?
> It definitely should since q.quit does not exist!

m.quit returns a callable function object, and () calls it.

If m.quit were to return some sort of error, then you would not be able to
assign it to something else. Eg: x = m.quit

However, I'm sure there are a lot of inadvertant errors that could have
been picked up if Python issued a warning if return results are not used
unless a special construct is employed. I'm sure this has all been gone
over before, but its fun... lets do it again:

Eg, say a function f  returned a value, and had a side effect (yes, this
is bad practise, but this is just an example, okay? :) Now say I wanted to
call this function f /just/ for the side effect:


With the scheme above, this would issue a warning. However, if the
language had a discard construct:

  discard f()

This would solve kwasi's problem. 'm.quit' would return a warning since
the value is not used anywhere. He (she?) would them either change that to
m.quit() as he intended, or add the 'discard' keyword, telling the
interpretor to suppress the warning.

Personally, I dont think its worth the extra work. I've learned not to
screw up so often ;)

   ("`-/")_.-'"``-._        Ch'marr, a.k.a.
    . . `; -._    )-;-,_`)  Chris Cogdon <chmarr at>
   (v_,)'  _  )`-.\  ``-'
  _.- _..-_/ / ((.'       FC1.3: FFH3cmA+>++C++D++H++M++P++R++T+++WZ++Sm++
((,.-'   ((,/   fL               RLCT acl+++d++e+f+++h++i++++jp-sm++

More information about the Python-list mailing list