Newbies: Re: Returning none

Evan Simpson evan at tokenexchange.com
Fri Sep 3 09:38:53 EDT 1999


I have the vague idea that someone else already suggested this, but I'm not
going to let that stop me:

Could we have a new singleton, perhaps called "Nothing", which is passed
back by empty "return"s and at the end of functions (and explicitly, if one
likes).  Have the code for function calls raise an exception if (1)
"Nothing" is being returned and (2) the next opcode is not "POP_TOP".

Make all builtins and standard library functions which act like "[].sort"
and "print_traceback" return "Nothing".  Now any attempt to use a
"procedure" except as a simple statement will raise an exception, and
functions can be explicit about whether or not they return a usable value.
Heck, a single function could even act as a "procedure" in some
circumstances and not in others.

Of course, adding "Nothing" means we have to wait for 2.0, right?

Paul Prescod <paul at prescod.net> wrote in message
news:37CF5499.BA24C33E at prescod.net...
> I want to make the empirical point that I brought up this None issue
> when two different co-workers ran into the problem in three different
> contexts in one statistically unlikely week.
>
> #1. a=list.sort("abc"): "None object has no attribute foo"
>
> #2. alert( print_traceback() ): "None"
>
> #3. Forgetting to return a value.







More information about the Python-list mailing list