[Python-3000] Abilities / Interfaces

Guido van Rossum guido at python.org
Thu Nov 23 00:19:26 CET 2006


I consider it a waste of time since the if-version works and there's
no reason for it to be extensible. There's only so much time we can
spend on each program before we move on; perfection isn't always
desirable, just working well enough.

Now if we had the nice syntax you propose I probably would have used
it. But I don't think Phillips' proposal is quite that smooth just
yet.

On 11/22/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Guido van Rossum wrote:
>
> > Examples that keep recurring are things like
> > the smtplib.SMTP.sendmail() method, whose second argument is either a
> > string or a list of strings. The optimal way of writing this, IMO, is
> > a single method that typechecks its 2nd argument. It currently uses
> > "if isinstance(x, basestring)" but I'd be happier if this could be
> > written as some kind of check for implementing the String interface.
> > (If it's neither a string nor a list, I don't really care what
> > happens, it will just raise an exception a few lines later and that's
> > perfectly fine for diagnosing the problem). Rewriting this as a
> > generic method (how do I even create generic methods? I'm sure it's
> > easy) sounds like a total waste of time and code.
>
> I'm not sure I see how changing
>
>      def sendmail(self, from_addr, to_addr, ...):
>          if isinstance(to_addr, basestring):
>               to_addr = [to_addr]
>         ...
>
> to, say
>
>      def sendmail(self, from_addr, to_addr is a string, ...): # specific
>          self.sendmail(from_addr, [to_addr], ...)
>
>      def sendmail(self, from_addr, to_addr, ...): # general
>          ...
>
> would be a *total* waste of time.  but maybe I've just done too much C#
> programming ;-)
>
> </F>
>
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list