while c = f.read(1)
Donn Cave
donn at u.washington.edu
Fri Aug 19 13:04:02 EDT 2005
In article <slrndgbole.209.apardon at rcpc42.vub.ac.be>,
Antoon Pardon <apardon at forel.vub.ac.be> wrote:
...
> But '', {}, [] and () are not nothing. They are empty containers.
Oh come on, "empty" is all about nothing.
> And 0 is not nothing either it is a number. Suppose I have
> a variable that is either None if I'm not registered and a
> registration number if I am. In this case 0 should be treated
> as any other number.
>
> Such possibilities, make me shy away from just using 'nothing'
> as false and writing out my conditionals more explicitly.
Sure, if your function's type is "None | int", then certainly
you must explicitly check for None. That is not the case with
fileobject read(), nor with many functions in Python that
reasonably and ideally return a value of a type that may
meaningfully test false. In this case, comparison (==) with
the false value ('') is silly.
Donn Cave, donn at u.washington.edu
More information about the Python-list
mailing list