November 21, 2007
Return Triumphant, Or Not At All

Returning None is Evil. I agree. I've always subscribed to the Samurai Principle myself. If you allow nulls to float around you inevitably end up with NPEs. These can be hard to diagnose properly; not only do you not know if null is actually invalid, but if it is, it's often non-trivial to work out where it came from.

Posted to Java by Simon Brunning at November 21, 2007 10:28 AM
Comments

> If you allow nulls to float around you inevitably end up with NPEs

Er? Python None is not the same as a null. Further, Python doesn't *have* pointers, and thus doesn't have null-pointer errors.

If you have a point here, I don't see it.

Posted by: bignose on November 22, 2007 10:35 PM

In Python, you get an AttributeError instead, but it amounts to the same thing.

And Python has pointers to *exactly* the same extent that Java does.

Posted by: Simon on November 23, 2007 09:12 AM

I don't see the big deal between:

try:
obj = somefunc()
except SomeException:
handle_problem

and

obj = somefunc
if obj is None:
handle_problem

Posted by: njharman on December 1, 2007 10:11 PM
Post a comment
Name:


Email Address:


URL:



Comments:


Remember info?