function returns

steve holden sholden at
Tue Jul 13 00:06:25 CEST 2004

Bart Nessux wrote:
> When one returns x from a function, is x available in other functions or 
> scopes within Python? Also, does it matter ehat the type (str, int, 
> float, list, etc.) of x is?

When opne returns x from a function then x is a reference to a value, 
and as long as that reference is assigned to a name outside the function 
it will be "kept alive" - in other words, the scope of a value is 
dynamic, unlike the scope of names.

Different calls to the same function are quite at liberty to return 
values of different types, although this would usually be considered a 
somewhat perverse way to behave.


More information about the Python-list mailing list