Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38418

Re: PyWart: Namespace asinitiy and the folly of the global statement

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'args': 0.04; 'sys': 0.05; 'class,': 0.07; 'level,': 0.07; 'builtins': 0.09; 'imports': 0.09; 'def': 0.10; 'programmer': 0.11; 'count.': 0.16; 'foo():': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'identifiers.': 0.16; 'increment': 0.16; 'wrote:': 0.17; 'variables': 0.17; 'examples': 0.18; 'feb': 0.19; 'module': 0.19; 'variable': 0.20; 'import': 0.21; 'file:': 0.22; 'skip:_ 20': 0.22; 'example': 0.23; 'header:In-Reply-To:1': 0.25; 'module.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'block,': 0.29; 'things,': 0.29; 'this.': 0.29; 'fri,': 0.30; 'johnson': 0.32; 'qualify': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'level': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'list,': 0.39; 'skip:" 10': 0.40; 'your': 0.60; 'containing': 0.61; 'skip:a 40': 0.61; 'making': 0.64; 'skip:n 40': 0.72; '2013': 0.84; 'actually,': 0.84; 'qualified:': 0.84; 'rick': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=9z6wqdl/XykltTys0x9bP3qs/bVj06HUwcepsYAkuxw=; b=RXIj+uct8GqaiU9XSw8wUj2dP4TZ1Sr6ONJvCrOYsp/205hsZmLCVyeSQLoIFohOJv Hfa88Samgk7Ge38nQWcZFEUDuD6Ula77wIMmqkUQ/dMmAfMVnjPusvInWauyu5vWQ/bB DnCWZtQu6M+v80uzyiGL6IHSxGYyjc0g8oPpzf137JDbPN8DxpfRHwJJRrel/UHxtXOK OWKJXfqOX2oXdlXgHxf558KakK/7IuYLmpYKXikVb9AamZceDnwxv0PXGj9BlwZgGeKP KLJUO2Ir2LLJDP4G2LX7xfZJkLCRt3/Ez0uR8TcxS0OwRiu5pUCan2yLS/xG5obtkJhI peCQ==
MIME-Version 1.0
X-Received by 10.52.22.194 with SMTP id g2mr4615186vdf.91.1360304734672; Thu, 07 Feb 2013 22:25:34 -0800 (PST)
In-Reply-To <02ced8e2-5967-4ce0-b257-83c3a3fbaf8e@googlegroups.com>
References <02ced8e2-5967-4ce0-b257-83c3a3fbaf8e@googlegroups.com>
Date Fri, 8 Feb 2013 17:25:34 +1100
Subject Re: PyWart: Namespace asinitiy and the folly of the global statement
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1484.1360304743.2939.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1360304743 news.xs4all.nl 6987 [2001:888:2000:d::a6]:37358
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:38418

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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