Syntax Error
Fredrik Lundh
fredrik at effbot.org
Sun Feb 4 03:00:19 EST 2001
kwasi007uk at yahoo.co.uk 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!
Python hasn't changed much since you last asked this
question...
>>> import poplib
>>> mailbox = poplib.POP3("localhost")
>>> mailbox.user("spam")
'+OK User name accepted, password please'
>>> mailbox.pass_("egg")
'+OK Mailbox open, 191 messages'
>>> mailbox.exit
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'POP3' instance has no attribute 'exit'
exit didn't exist.
>>> mailbox.quit
<method POP3.quit of POP3 instance at 008AC4EC>
quit sure exists -- it's a method (a callable object).
if you want, you can store that method in a variable
for later use, or pass it to a function, etc.
>>> callback = mailbox.quit
>>> callback
<method POP3.quit of POP3 instance at 008AC4EC>
>>> callback()
'+OK Sayonara'
Cheers /F
More information about the Python-list
mailing list