[Python-checkins] python/dist/src/Lib ftplib.py,1.66,1.67

Guido van Rossum guido@python.org
Wed, 08 May 2002 12:02:31 -0400


> Is this patch a good idea? Now you can pass all sorts of garbage as 
> callback (callback="hello") and it'll be silently ignored. I would think 
> something like "if not callback is None:" or so would be better...

I think Martin will change it to that, yes.

> And in general I think it's unwise in Python to have an object that 
> tests false (because it's __len__ returns 0, in the case of this bug 
> report) but is still expected to do something. "if object: 
> do_something_with(object)" is fairly standard Python idiom.

But it's a time bomb waiting to go off!  The correct code should read
"if object is not None: do_something_with(object)".  There are lots of
objects that (for better or for worse!) define __len__.  So beware.

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