returning none when it should be returning a list?

Fredrik Lundh fredrik at pythonware.com
Mon May 1 11:16:44 EDT 2006


randomtalk at gmail.com wrote:

> John Machin wrote:
> >
> > That's because it "falls off the end" of the function, which causes it
> > to return None. However that's not your only problem. Major other
> > problem is updating "seed" in situ.
> >
> I'm not sure what "falls off the end" of the function means, i searched
> online, it seems to mean that the function has reached the end
> prematurely and returned a default identifier to signal success or
> not.. Can you please explain what that means?

it means exactly what it says: that execution of the function body reaches
the end of the function without seeing an explicit "return" statement.

Python handles this by inserting an extra "return" statement at the end, to
make sure there's always something to return (a plain "return" returns None
to the caller).

</F>






More information about the Python-list mailing list