Boolean tests [was Re: Attack a sacred Python Cow]
Antoon Pardon
apardon at forel.vub.ac.be
Fri Aug 1 04:35:12 EDT 2008
On 2008-08-01, Erik Max Francis <max at alcyone.com> wrote:
> 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.
So you accept my point that "if x" can be less polymorphic
and in fact can be more confusing than a more specific test.
--
Antoon Pardon
More information about the Python-list
mailing list