function returns
steve holden
sholden at holdenweb.com
Mon Jul 12 18:06:25 EDT 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.
regards
Steve
More information about the Python-list
mailing list