Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Namespaces are one honking great idea Date: Sat, 2 Jul 2016 03:13:21 +1000 Lines: 29 Message-ID: References: <57767a97$0$1606$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 8PBTsY2XjMn6UA2VQsWwvAju/ZGr+pq2mpcAc3F/y1Yg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python3': 0.05; 'cc:addr :python-list': 0.09; 'namespace': 0.09; 'python': 0.10; 'def': 0.13; '2016': 0.16; 'c():': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Namespaces': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'sat,': 0.23; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; 'linux': 0.26; 'error': 0.27; 'message-id:@mail.gmail.com': 0.27; 'skip:( 20': 0.28; 'print': 0.30; 'extend': 0.31; "can't": 0.32; 'knows': 0.32; 'class': 0.33; 'received:google.com': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'thought': 0.37; 'why': 0.39; 'more': 0.63; 'capabilities': 0.72; 'jul': 0.72; '5.3.1': 0.84; 'chrisa': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=uIpCmbDT/3yNu1/bia1QCRCE1AgZM8Lnx7aclRB/0Kc=; b=EeRnZa3wGHBC7F9SX3LQN/dbkENMp2PUmK94hmlz9/LxyRB+jpX2IHXtruGOg3IIVZ oEaH8qbBMM612fQRJUw4ET6qx3LK7CkFVoj1LqbyHabUX7YQuGF0R86wfbVpqYh4csCx 0wwSetXliMJqWtQC9jKTEsE7PVflP/MEYuGwkYuOn4RYRP/8PvrusOG83YSe5xFeEg/A pEDf4JALHC5KspCGBYUZ25/MK+fVZq2qUeVMi11ZNis7phFedDnLa37Hs41po7Yx958B txKrKdikAHBSMUww0+yFrB1pEtl8Aj6OpQQhlHeGomSraOQpCyOFdCG4G1m2jw5TwUsr F4gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=uIpCmbDT/3yNu1/bia1QCRCE1AgZM8Lnx7aclRB/0Kc=; b=K2BATaNcB3fIdfnifog1LWAAmp8Yvpu5IfGLLLEQsPUtLEWErn8GhdFZsaCvXblw0V BLoylhrGtorHbz73phCTn2aQ0f5D8IdsUmTQtOwSbSgQKGSY/SbGYo+g3en5bFhZ3M9e 4YXa86j+PX0GEf8u35vsl2oD4JMyD63muV2MsyzLYKRgQaLTchgXUzq/q7j7+nrCKcUV shRlBClUWcmTKanMijJCWIAGWn/dXGI726SsvAPmifTOuaUsx5xY6qpuSp8R8xoy0IEy BVbl5YEvzwk4pGgfBDHiyolb2eOZS9TapgUdH7ZZmpKjO2C6NhLUoh1kKWn3S+UbeZwZ +mkQ== X-Gm-Message-State: ALyK8tK0h9owj6wWpHe01qJXFcrq2XD2TE/7HtBXG18RR0Z8Khn2OkY8Y97oGjBP1x2tEF2itlKRZSdZ9AcBSA== X-Received: by 10.194.70.41 with SMTP id j9mr4634483wju.30.1467393202270; Fri, 01 Jul 2016 10:13:22 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <57767a97$0$1606$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:110910 On Sat, Jul 2, 2016 at 12:49 AM, BartC wrote: > Why not just extend the capabilities of a class? I actually thought this > would work until I tried it and it didn't: > > class C(): > def fn(): > print ("Hi!") > > C.fn() > > The error message suggests Python knows what's going on. So why not just > make it work? rosuav@sikorsky:~$ python3 Python 3.6.0a2+ (default:57f3514564f6, Jun 29 2016, 16:27:34) [GCC 5.3.1 20160528] on linux Type "help", "copyright", "credits" or "license" for more information. >>> class C(): ... def fn(): ... print ("Hi!") ... >>> C.fn() Hi! >>> But if you have two such functions, they can't call each other without the namespace marker. ChrisA