Returning none

Magnus L. Hetland mlh at idt.ntnu.no
Thu Aug 26 14:34:01 EDT 1999


Skip Montanaro <skip at mojam.com> writes:

>     Jeff> I think this proposal would break too much existing code, even for
>     Jeff> a Python 2 change.
[...]
> 
> How about a compromise?  Perhaps Aaron Watters' PyLint can be modified to
> bitch about functions without a return as the last statement?

Well... That would be a bit to strict, wouldn't it? As long as you
don't use the return value, there's no point in returning anything...
So what it probably *should* do, is argue when you assign the return
value of a function without a return as a last statement to a
variable... But that isn't possible, of course, since functions can be
assigned dynamically.

And - it might not even be true that it should be the last statement.
The return value might only be used in situations where the functions
returns a value earlier in its body...

So - this seems difficult to me. Only solution is a runtime error -
which would, of course, break a lot of code.

--

  Magnus              Making no sound / Yet smouldering with passion
  Lie          The firefly is still sadder / Than the moaning insect
  Hetland                                       : Minamoto Shigeyuki




More information about the Python-list mailing list