return None

Grant Edwards grante at visi.com
Fri Jul 22 14:14:22 EDT 2005


On 2005-07-22, Roy Smith <roy at panix.com> wrote:
> In article <3kcpbbFtjttlU1 at individual.net>, Ximo <elrei69 at yahoo.es> wrote:
>>Can I do a function which don't return anything?
>>
>>The question is that, if I do a function that have a return or without 
>>return, it returns always "None", but i want that it doesnt return me 
>>nothing
>
> What do you mean by "don't return anything", as oppossed to returning
> None?  Let's say I had one of those functions, and did:
>
> foo = noReturnValue()
> print foo
>
> what would you expect (want?) to happen?

One supposes that if noReturnValue() really didn't return
anything, then the above code would cause an exception.

Personally, I don't really like the idea that falling off the
botton of a function implicitly returns None.  It's just not
explicit enough for me.  My preference would be that if the
function didn't execute a "return" statement, then it didn't
return anyting and attempting to use a return value would be an
error.

I suppose there probably is code out there that depends on the
implicit "return None" at the end of every function, so it's
too late to change things now.

-- 
Grant Edwards                   grante             Yow!  Is it FUN to be
                                  at               a MIDGET?
                               visi.com            



More information about the Python-list mailing list