Returning none

C.Laurence Gonsalves clgonsal at keeshah.penguinpowered.com
Thu Sep 2 20:51:35 EDT 1999


On Mon, 30 Aug 1999 20:30:11 GMT, Michael P. Reilly <arcege at shore.net> wrote:
> 
> I'm guessing that most everyone has forgotten what "None" _is_.  From
> Python Reference Manual: 3.2 "The standard type hierarchy":
> 
>    None
>           This type has a single value. There is a single object with
>           this value. This object is accessed through the built-in name
>           None. It is used to signify the absence of a value in many
>           situations, e.g., it is returned from functions that don't
>           explicitly return anything. Its truth value is false.
> 
> The key here folks is "the absense of a value".  None means "nothing at
> all" that the "procedure" proponents are all for.  It's doing exactly
> what you want, you may just be thinking of it incorrectly (we all are
> probably thinking of None incorrectly at times).
> 
> If you want to not include "return" in your functions, or to require
> that your code must "return None" that's fine.  I think that the
> argument is that the language is not going to improve by requiring
> procedures.

But None *isn't* nothing at all. If it was, [None] would be the same as
[], and calling str(None) would be the same as str(). They're different
though.

None is *something*. You can copy it around, put it into
lists/tuples/maps/attributes, and pass it to functions. That can cause
problems if you meant to pass the result of some computation, and your
function was incorrectly not returning the result, but instead the
default None.

-- 
  C. Laurence Gonsalves            "Any sufficiently advanced
  clgonsal at kami.com                 technology is indistinguishable
  http://www.cryogen.com/clgonsal/  from magic." -- Arthur C. Clarke




More information about the Python-list mailing list