How "return" no return ?

François Pinard pinard at iro.umontreal.ca
Thu May 12 11:53:16 EDT 2005


[Ximo]

> I want that the return sentence don't return anything, how can I do
> it?

`return' always return something (if we except the case of generators).
Used without arguments, it returns None, as you discovered already.
If a function "falls through" its end, None is implicitely returned.

A function always have a value.  I do not understand the need of "not
returning anything".  What do you mean?  What is the real need?

> [...] pass don't run too.

`pass' surely runs.  However, `pass' is not a `return' statement.

-- 
François Pinard   http://pinard.progiciels-bpi.ca



More information about the Python-list mailing list