Hmm..If I add a few debugging lines like that into my code, I get this:

Starting program
In class Hangman
done defs in class
eWordEntryBox defined
Exception in Tkinter callback
Traceback (most recent call last):
 File "C:\Python31\lib\tkinter\__init__.py", line 1399, in __call__
   return self.func(*args)
 File "C:/Users/Corey/Desktop/HangmanApp.py", line 48, in getLetter
   self.guess = eWordEntryBox.get()
NameError: global name 'eWordEntryBox' is not defined

I have the line "eWordEntryBox" right after the definition.

Emile van Sebille wrote:
The difference is in understanding what's executed and what's deferred.

Consider the following:

#-----Start File test.py-----
def test():
  print "in def test"

class Test:
  print "in class Test"
  def __init__(self):
    print "in class Test.__init__"

print "in __main__"

test()
t = Test()

#-----End File test.py-----

Output:

in class Test
in __main__
in def test
in class Test.__init__

-----------------

As you can see, the print statements at the class level are executing when encountered, but the prints in defs only when executed.

HTH,

Emile


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to