> Sent: Monday, September 11, 2017 at 10:03 AM > From: "João Matos" <jcrma...@gmail.com> > To: python-ideas@python.org > Subject: [Python-ideas] Give nonlocal the same creating power as global > > Hello, > > I would like to suggest that nonlocal should be given the same creating > power as global. > If I do > global a_var > it creates the global a_var if it doesn't exist. > ...
I think this is a bad idea overall. It breaks encapsulation. I would suggest you use create_vars() to return a context: context = create_vars() create_layout(context) create_bindings(context) Or use a class: class TkView: def __init__(self): self.tk = Tk() self.create_layout() self.create_bindings() def create_layout(self): # use self.tk def create_bindings(self): # use self.tk _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/