T
Thomas Philips
Here's a very simple program with an odd twist:
class Player(object):
def __init__(self,name):
self.name = name
hero = Player("A")
print "hero",hero
If I run it in IDLE and then type dir() at the prompt, I get
However, if I modify the program as follows
class Player(object):
def __init__(self,name):
self.name = name
def main():
hero = Player("A")
print "hero=",hero
main()
and then run it in IDLE and type dir at the prompt, I get
Why does 'hero' not appear in the workspace directory when main() is
invoked and vice versa?
Thomas Philips
class Player(object):
def __init__(self,name):
self.name = name
hero = Player("A")
print "hero",hero
If I run it in IDLE and then type dir() at the prompt, I get
['Player', '__builtins__', '__doc__', '__name__', 'hero']
However, if I modify the program as follows
class Player(object):
def __init__(self,name):
self.name = name
def main():
hero = Player("A")
print "hero=",hero
main()
and then run it in IDLE and type dir at the prompt, I get
['Player', '__builtins__', '__doc__', '__name__']
Why does 'hero' not appear in the workspace directory when main() is
invoked and vice versa?
Thomas Philips