question about True values
steve at REMOVE.THIS.cybersource.com.au
Fri Oct 27 16:03:52 CEST 2006
On Fri, 27 Oct 2006 12:54:35 +0100, Steve Holden wrote:
> Antoon Pardon wrote:
>> On 2006-10-27, Fredrik Lundh <fredrik at pythonware.com> wrote:
>>>Antoon Pardon wrote:
>>>>>since you never publish any code,
>>>>This is not True. You shouldn't confuse your lack of recollection
>> Sorry, the answer is no. I don't care whether you can locate my code
>> or not or wish to believe me or not.
> Google finds 2 hits for "Anton Pardoon open source". You are ceratinly
> keeping it well hidden.
> Few people have more right to call you on this than the effbot, well
> known for his prolific output.
This may come as a shock to some of us in the Open Source arena, but the
care-factor of code is not necessarily tied to the number of distinct
pieces of code released to the public by the code's author. Many people,
for example, care a lot about the software running in nuclear reactors,
regardless of whether or not the code's author is a prolific Open Source
Of course Fredrik has a proven track record, and the quality of his code
is out there for any interested person to see. That means that the wise
person, even if he disagrees with Fredrik, should take what he has to say
seriously. If Fredrik is dismissive of Antoon's use of "if len(list) != 0"
instead of "if list", we should take that opinion very seriously.
But for all we know, Antoon's code might be responsible for keeping
nuclear reactors running, planes in the air, missiles hitting their
targets, or some other really critical application. His lack of visible
code doesn't *necessarily* mean we should dismiss what he has to say -- it
merely means that his track record is unproven to us.
And even if he does nothing but write trivial scripts for his own use,
that fact alone doesn't make his opinion wrong or foolish.
But in this specific instance, I don't see any advantage to explicitly
testing the length of a list. Antoon might think that is sufficiently
polymorphic, but it isn't. He cares whether the object has zero _length_,
but for true polymorphism, he should be caring about whether the object is
_empty_. Not all empty objects have zero length, or even a length at all.
(E.g. binary trees.) That's why Python classes can use a __nonzero__
method, falling back on __len__ only if __nonzero__ is not defined.
More information about the Python-list