How "return" no return ?

Jeff Epler jepler at unpythonic.net
Fri May 13 09:01:18 EDT 2005


At the interactive prompt, a result is printed when both these things
are true:
    * The entered code is an expression, not any other kind of statement
    * The result of the expression is not 'None'
If an expression occurs, information about it will be printed instead.

So the interpreter won't print a result for
    >>> a = 3            # because it's an assignment statement
    >>> def f(): return  # because it's a 'def' statement
    >>> None             # because the result of the expression is 'None'
    >>> f()              # because the result of the expression is 'None'

Your example
    >>> int a
is not Python, but if it was it would probably be a non-expression
statement, and thus never print a result in the interpreter.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050513/c9e546e7/attachment.sig>


More information about the Python-list mailing list