checking if a list is empty

Laurent Claessens moky.math at gmail.com
Wed May 11 07:45:05 EDT 2011


> I believe you are grossly oversimplifying whatever code you had. Using
> the definition of f from above:
>
>>>>  theta = math.pi/4
>>>>  f(math.cos(2*theta))
> 6.12303176911e-17

Yes: its oversimplifued. The angle come from a normal vector of a curve 
and so on.... In particular, I was using Sage; the computations are 
exact: pi is pi and cos(pi) is zero.

>>  Conclusion: the boolean value of an object is to be used with care in
>>  order to tests if an optional parameter is given or not (when default
>>  value is None).
>
> Or, to put it another way: if you want to test for an object being None,
> test for the object being None.

It was my conclusion too ;)

Laurent



More information about the Python-list mailing list