Declaration of an array of unspecified size
Anton Vredegoor
anton at vredegoor.doge.nl
Mon Sep 1 05:19:25 EDT 2003
"Ulrich Petri" <ulope at gmx.de> wrote:
>An optimzed (untested) version:
>
>class PopMailServer:
> def __init__(self, host, user, pass):
> self.host = host
> self.user = user
> self.password = pass
> self.mail = []
>
> def action(self):
> pop = poplib.POP3(self.host)
> pop.user(self.user)
> pop.pass_(self.password)
> for x in p.list()[1]:
> num, len = x.split()
> self.mail.append(pop.retr(num)[1])
> pop.quit()
> print "Total mails: %d" % len(self.mail)
>
>of course this lacks exception handling...
You followed the OP into using "pop" as a name for an instance.
However "pop" is also a *method* of type list. While it's not as bad
as for example using the name "str" for a string ("str" is a build-in
function which is not reachable anymore if it's name is used this way)
this still makes my spider sense tingle. Whether it's because you
failed to mention this or just because it's dialectical I don't know
:-)
Anton
More information about the Python-list
mailing list