[Python-ideas] Give nonlocal the same creating power as global
Jason H
jhihn at gmx.com
Mon Sep 11 10:26:10 EDT 2017
More information about the Python-ideas mailing list
Mon Sep 11 10:26:10 EDT 2017
- Previous message (by thread): [Python-ideas] Give nonlocal the same creating power as global
- Next message (by thread): [Python-ideas] Give nonlocal the same creating power as global
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Sent: Monday, September 11, 2017 at 10:03 AM > From: "João Matos" <jcrmatos at gmail.com> > To: python-ideas at 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
- Previous message (by thread): [Python-ideas] Give nonlocal the same creating power as global
- Next message (by thread): [Python-ideas] Give nonlocal the same creating power as global
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list