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: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Fri, Feb 8, 2013 at 3:30 PM, Rick Johnson 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 +=3D 1 Or are you going to make builtins and imports magically available as PHP-style superglobals? ChrisA