Hello
I provide two almost identical small test case programs.
The first one works as expected, 'True' is printed on the
console.
With the second one Python complains that 'test' is not
known. I dont understand why.
Python 3.4, windows
#####################
## First
#####################
from tkinter import *
import tkinter.simpledialog
class MyDialog(tkinter.simpledialog.Dialog):
def body(self, master):
print(test)
def apply(self):
pass
root = Tk()
test = True
setup = MyDialog(root)
# 'True' is printed on the console. Works !
#####################
## Second
#####################
from tkinter import *
import tkinter.simpledialog
class MyDialog(tkinter.simpledialog.Dialog):
def body(self, master):
print(test)
def apply(self):
pass
def try_():
test = True
setup = MyDialog(root)
root = Tk()
try_()
# NameError: name 'test' is not defined
--
https://mail.python.org/mailman/listinfo/python-list