Scope of instantiated class
Jim Jinkins
j-jinkins at usa.net
Sun Jul 21 20:55:48 EDT 2002
Jeff Layton wrote:
> Hello,
>
> If I instantiate a class in a function,
> leave the function via a return and then
> go back to the same function, will the
> instantiation of the class still be there
> or is it local to the function so it is
> "destroyed"? (Does this make any sense?)
>
> TIA,
>
> Jeff
>
A class defined _and referenced_ only within the function is local.
If the function returns the class to a name, that name holds the class
definition. You can instantiate objects of the class using the 'class
name' returned by the function.
Or so says _my_ interpretation of the tutorial.
Jim
More information about the Python-list
mailing list