Complaint Dept: My shoes!

Martijn Faassen m.faassen at vet.uu.nl
Fri Apr 14 15:27:33 EDT 2000


Moshe Zadka <moshez at math.huji.ac.il> wrote:
> On Thu, 13 Apr 2000 musingattheruins at my-deja.com wrote:

>> If shoe is None then len(shoe) raises an exception.  Would be nice if
>> len(None) was 0 and NOT raise an exeption.

> Huh? Why not have len(None) 4? Or -1?
> If you want an empty string, use an empty string. The good thing
> about None is that it supports so few operations, functions not expecting
> it would break right away, instead of having a hidden bugs.

I agree completely. You DON'T want len(None) to not raise an exception.
It's good that it does. I agree with all posters. Don't do it. Don't.

...

And now I'm going to tell you how to make len(None) return 0. This
is an implementation detail. It's a *bug* that ought to be fixed.

Put this in the module where you want len(None) to be 0:

None = ""

Now it works as you want. But you *don't* want to want this. If you go
down on this path, the Python Secret Underground will come and destroy you.
Perhaps retroactively wipe you out. The only good thing that may come
out of this is Guido going back in his time machine to fix this. Just don't
do it.

This-is-not-what-G*d*-indented!-ly yours,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list