poplib for multihomed machines

Donn Cave donn at u.washington.edu
Tue Jun 29 14:59:58 EDT 2004


In article <9418be08.0406291005.34d4277b at posting.google.com>,
 elbertlev at hotmail.com (Elbert Lev) wrote:
> Donn Cave <donn at u.washington.edu> wrote in message 
> news:<donn-52178C.11032728062004 at gnus01.u.washington.edu>...
> > In article <9418be08.0406280751.6cc50097 at posting.google.com>,
> >  elbertlev at hotmail.com (Elbert Lev) wrote:
...
> > > The problem with POP3 class is: it connects during __init__ and it is
> > > "hard coded". I do not see any way to change this behavior with no
> > > rewrite of POP3 class.
> > > 
> > > Do you?
> > 
> > Well, no.  It should probably use an open() method like imaplib's.
> > 
> >    Donn Cave, donn at u.washington.edu
> 
> 
> This is a major design error. NO-NO is C++. Constructor is supposed
> only initialise members and take no actions. Unfortunatelly this
> paradigm is violated in many Python classes.

Well, C++ is NO-NO for sure, but for the rest I think in
the Python world it's better to stick to what works and
what doesn't.

The standard core library classes often seem to me to be
designed in fairly conscious recognition of the fact that
they're lightweight.  If you need to make minor, or major,
changes to support your application, I think that happens
fairly often, and it isn't a big problem.  If a new release
of poplib introduces a feature you want, it's easy to copy
it into your version.  I know that sounds awful, but we're
software engineers, right?  Not theoreticians, not priests
of some software cult.  We should know the difference between
a real problem and a theoretical problem.  The whole thing
is only 335 lines in 2.2.

Meanwhile, for the casual application that's really served
by these classes, convenience is king.  You will find __init__
functions taking "actions" because that relieves the user
of a need to know extra steps.  If there's a practical need
to decouple POP3 instantiation from the network connection,
then I'm sure its author will be interested (though of course
by now there will be some backwards compatibility issues.)
If the practical issues can be resolved by factoring the
network connection out into a separate function, then that's
a practical solution, don't you think?

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list