alf wrote:
> Hi,
>
> I have a reference to certain objects. What is the most pythonic way to
> test for valid reference:
>
>       if obj:
>
>       if None!=obs:
>
>       if obj is not None:

I like this way the most. I used timeit to benchmark this against the
first one, expecting it to be faster (the first is a general false
test, the last should just be comparing pointers) but it's slower.
Still I don't expect that to ever matter, so I use it wherever I wish
to test for None, it reads the best of all of them.

-Sandra

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to