Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38418
| References | <02ced8e2-5967-4ce0-b257-83c3a3fbaf8e@googlegroups.com> |
|---|---|
| Date | 2013-02-08 17:25 +1100 |
| Subject | Re: PyWart: Namespace asinitiy and the folly of the global statement |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1484.1360304743.2939.python-list@python.org> (permalink) |
On Fri, Feb 8, 2013 at 3:30 PM, Rick Johnson
<rantingrickjohnson@gmail.com> wrote:
> It is my strong opinion that all "unqualified" variables must be local to the containing block, func/meth, class, or module. To access any variable outside of the local scope a programmer MUST qualify that variable with the func, class, or module identifiers. Consider the following examples
Okay. Now start actually working with things, instead of just making
toys. All your builtins now need to be qualified:
__builtins__.print("There
are",__builtins__.len(self.some_list),"members in this list,
namely:",__builtins__.repr(self.some_list))
And your imports happen at module level, so they need extra qualification:
# file: example.py
import sys
def foo():
__builtins__.print("My args were:",example.sys.argv)
Actually, you already ran up against this. Your example needs to become:
for x in __builtins__.range(100):
# Increment the module level variable count.
example.count += 1
Or are you going to make builtins and imports magically available as
PHP-style superglobals?
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PyWart: Namespace asinitiy and the folly of the global statement Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 20:30 -0800
Re: PyWart: Namespace asinitiy and the folly of the global statement Michael Torrie <torriem@gmail.com> - 2013-02-07 23:21 -0700
Re: PyWart: Namespace asinitiy and the folly of the global statement Chris Angelico <rosuav@gmail.com> - 2013-02-08 17:25 +1100
Re: PyWart: Namespace asinitiy and the folly of the global statement Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 23:23 -0800
Re: PyWart: Namespace asinitiy and the folly of the global statement Chris Angelico <rosuav@gmail.com> - 2013-02-08 18:28 +1100
Re: PyWart: Namespace asinitiy and the folly of the global statement Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 23:23 -0800
Re: PyWart: Namespace asinitiy and the folly of the global statement Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-08 22:29 +1100
Re: PyWart: Namespace asinitiy and the folly of the global statement Chris Angelico <rosuav@gmail.com> - 2013-02-08 22:38 +1100
Re: PyWart: Namespace asinitiy and the folly of the global statement Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-08 22:45 +1100
Re: PyWart: Namespace asinitiy and the folly of the global statement Michael Torrie <torriem@gmail.com> - 2013-02-08 21:25 -0700
Re: PyWart: Namespace asinitiy and the folly of the global statement alex23 <wuwei23@gmail.com> - 2013-02-10 18:42 -0800
Re: PyWart: Namespace asinitiy and the folly of the global statement Chris Angelico <rosuav@gmail.com> - 2013-02-11 17:27 +1100
Re: PyWart: Namespace asinitiy and the folly of the global statement Jason Swails <jason.swails@gmail.com> - 2013-02-11 13:32 -0500
Re: PyWart: Namespace asinitiy and the folly of the global statement Michael Torrie <torriem@gmail.com> - 2013-02-11 12:15 -0700
Re: PyWart: Namespace asinitiy and the folly of the global statement Chris Angelico <rosuav@gmail.com> - 2013-02-12 08:11 +1100
csiph-web