Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.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; 'instance': 0.05; 'python': 0.07; 'correct.': 0.09; 'definitions.': 0.09; 'namespace': 0.09; 'wrote:': 0.14; 'global,': 0.16; 'lookup': 0.16; 'subject:Namespaces': 0.16; 'subject:classes': 0.16; 'to:name :python-list (general)': 0.16; 'to:2**1': 0.20; 'received:209.85.220': 0.26; 'classes': 0.26; 'function': 0.27; 'message-id:@mail.gmail.com': 0.28; 'helpful': 0.29; 'definition': 0.29; 'class': 0.29; 'all.': 0.30; 'does': 0.31; 'however,': 0.31; 'separate': 0.31; 'to:addr:python-list': 0.32; 'received:209.85': 0.37; 'received:google.com': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'local,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=93CAg5ci6Vdqd38cG2gIvMw6xDyGkpyK6C4ZcCuiA0I=; b=knuOA6Eu8GB6bPNr1BHqCda3ml9OS30E1Vmc8UtJCmWH5WcxpedHoLDxM+6vUBAIvs FMQEBwzn12LzIYB5TvjAZUTE6UGTQHERe0MN4MNB4Jru0cpqhjnzbXe6giFq2fNGq+4V HXHD48y8FCLtOwqUoN4KPmqfLnPOckhMW2GgA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=g3KLd39YjsT0+K8CgZL6RT6Pl5aoTG+nXXMW1kmi4BKfZ9DsiSPWkGIXoxW7ptsg1K cKyoXHqQtHsbURmaddAjh6QSWuvGgXrTk06l82ag6+vnahaMNhzE7cdO0mWDkPAHZkbH 9MXJiknFQgs7TUEmrYGxSzUpiuBipzZtE9nEw= MIME-Version: 1.0 Date: Tue, 19 Apr 2011 12:47:40 -0400 Subject: Re: Namespaces in functions vs classes From: Gerald Britton To: Ethan Furman , "python-list (General)" Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 19 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303231665 news.xs4all.nl 81485 [::ffff:82.94.164.166]:33120 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3571 >Gerald Britton wrote: >> I now understand the Python does >> not consider a class definition as a separate namespace as it does for >> function definitions. That is a helpful understanding. >That is not correct. Classes are separate namespaces -- they just >aren't automatically searched. The only namespaces that are >automatically searched are local, non-local, global, and built-in. I see you misunderstood my observation: Python does not consider a class definition as a separate namespace *as it does* for function definitions. Of course classes are separate namespaces, or they would not work at all. However, Python does not automatically search class namespaces -- even within the class definition -- *as it does* within function definitions. That is the key insight I was seeking. To search a class namespace one must qualify the lookup with the class or instance name.