Returning values from function to Python shell/IPython

Gabriel Genellina gagsl-py2 at
Mon Mar 10 06:07:42 CET 2008

On 9 mar, 20:51, castiro... at wrote:

> While you're at it, can you call up prior source, and edit it?  BASIC
> had line numbers:
> 10 def f( a ):
> 20   return a+ 1
> >>> 15 print( a )

Not so easy. The current CPython implementation assumes that once an
object is allocated, it is never moved to another memory location. If
doing that were allowed, all the object references had to be updated,
or another level of indirection would be required, and neither
alternative looks very promising.
The reload function tries to reuse the module object itself, but its
contents are destroyed and recreated. Maybe for some simple changes
like the above the *same* function object could be re-utilized, but
not in the general case.

Gabriel Genellina

More information about the Python-list mailing list