Re: return None
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: return None

From: Grant Edwards <grante@visi.com>
Date: Fri Jul 22 2005 - 20:14:22 CEST

On 2005-07-22, Roy Smith <roy@panix.com> wrote:
> In article <3kcpbbFtjttlU1@individual.net>, Ximo <elrei69@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            
Received on Thu Sep 29 17:06:29 2005