Boolean tests [was Re: Attack a sacred Python Cow]

Erik Max Francis max at alcyone.com
Fri Aug 1 04:08:25 EDT 2008


Antoon Pardon wrote:

> I now have the following question for people who argue that "if x"
> is more polymorphic. I could subclass list, so that instances
> of this new sequence would always behave as true, even if they are
> empty.  I could then rewrite my loop as follows:
> 
> while 1:
>   extra = produce()
>   if not extra:
>     break
>   for el in extra:
>     adjust_with(el)
>   calculate()
> 
> Is this second loop now more polymorphic as the first?

It's more confusing since you've changed the standard behavior of a 
standard type, which doesn't really have anything to do with 
polymorphism.  It's more confusing, if that's a benefit.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   In a cosmic setting, vast and old, beyond ordinary human
    understanding, we are a little lonely. -- Carl Sagan, 1934-1996



More information about the Python-list mailing list