Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111094
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Namespaces are one honking great idea |
| Date | Tue, 5 Jul 2016 13:47:41 +1000 |
| Lines | 27 |
| Message-ID | <mailman.82.1467690470.2295.python-list@python.org> (permalink) |
| References | <57767a97$0$1606$c3e8da3$5496439d@news.astraweb.com> <nldgv7$2e0$1@ger.gmane.org> <mailman.65.1467631737.2295.python-list@python.org> <577b1cc6$0$1584$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmp5-T+qnOY-1K_txs+bC5gofNBp1EVqmaKW7dnsOD5Whw@mail.gmail.com> <mailman.81.1467687507.2295.python-list@python.org> <577b2af3$0$1611$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmoU=iRkn3PmeOxk9+=vuuvVzO-CQrd_TtXF52Bjq-Vr9Q@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de l9Ng/+Ys10SH6MSfg3vPAAmxDulj7hb9RMXZlaOUPM2w== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '(even': 0.05; 'cc:addr :python-list': 0.09; 'builtins': 0.09; 'inserted': 0.09; 'module)': 0.09; 'namespace': 0.09; 'def': 0.13; 'file,': 0.15; 'importing': 0.15; '(do': 0.16; '.py': 0.16; '2016': 0.16; '999': 0.16; 'ah,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'namespace,': 0.16; 'namespace?': 0.16; 'out"': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Namespaces': 0.16; 'test():': 0.16; 'wrote:': 0.16; 'nested': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'work,': 0.21; '(the': 0.22; 'do.': 0.22; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'sense': 0.26; 'not.': 0.27; 'separate': 0.27; 'message-id:@mail.gmail.com': 0.27; 'resolution': 0.28; 'code': 0.30; 'push': 0.30; 'class': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'tue,': 0.34; 'file': 0.34; 'received:google.com': 0.35; 'necessary.': 0.35; 'path': 0.35; 'but': 0.36; 'should': 0.36; 'modules': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'does': 0.39; 'your': 0.60; 'real': 0.62; 'jul': 0.72; '"just': 0.84; 'chrisa': 0.84; 'question!': 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=y/9vTNPWqUTFxVAF1c+1gtf6h7nSCvHZ/E8S/65vJK8=; b=SzXDYkXF8GdGSSBx/gwtbW0CW0fcLKGJTp50txa+c/xVKB5hruvXjzmXaDd3wJTtt9 ozGjsi6xUjHNpQ8pQ2t0np5Hrfd/VU3qBj0aePC15HisVNAkuB2oxBS2GUybr/6WKiUO kELKxWooNMRzKUxEh+Z+rk/cMp6dgnHMure0HouEBJg38+axtx5OzTBadjeN3NftcMDR OU5JpXEWrHc4erXGOuoZIk6RbSqzTEvkKjls/3YeSBr/fCQtCxpAI+q5DqeGRFv5wpBs XlJncPw+/5+mT0MOikphR4Z4bYoorL1nmgek8gUJWj8z+9qQKmhzf50uq6N5+SJewey4 Wc1w== |
| 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=y/9vTNPWqUTFxVAF1c+1gtf6h7nSCvHZ/E8S/65vJK8=; b=fPRl0awYpEPPkuZGSr3m40m/od01wgPxHvV1p5CHt3h87WAZ4Emx5oFpyHpoByj6vz LUyeunzNeqNKDG+gOum8n/9+OVhe6HxxCYYte5jXF3V9Id/b/RzMog8B4nfNzfqQTi83 pGDtHePqx2Z/DRffcxhNOzQu/SK/NtXSYhae6mHxGBxw6hGsERXNuH3e4k+0w7keO7jz dqtACpjdLg2EDZDwfu64w/IlGIuH6MWd9Ow6SU8XT3A7LI19ykP0N+a5d6+kZWrPfR46 BVN/8QXCu/mkd0zY303Z3ZnVLb+wg0Xz+ALdwXhInzOKO2n8ZQga+GyLAkbIoAeu5Dd+ VOPw== |
| X-Gm-Message-State | ALyK8tJ120C8De3352Vu4CpyZAEDQedFWM4FpFDPYj+4/Rwp5IxV4/a28JL1sbl+3AQbFlJYo/DirhfXC0vZ8Q== |
| X-Received | by 10.28.44.131 with SMTP id s125mr12998224wms.61.1467690462445; Mon, 04 Jul 2016 20:47:42 -0700 (PDT) |
| In-Reply-To | <577b2af3$0$1611$c3e8da3$5496439d@news.astraweb.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CAPTjJmoU=iRkn3PmeOxk9+=vuuvVzO-CQrd_TtXF52Bjq-Vr9Q@mail.gmail.com> |
| X-Mailman-Original-References | <57767a97$0$1606$c3e8da3$5496439d@news.astraweb.com> <nldgv7$2e0$1@ger.gmane.org> <mailman.65.1467631737.2295.python-list@python.org> <577b1cc6$0$1584$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmp5-T+qnOY-1K_txs+bC5gofNBp1EVqmaKW7dnsOD5Whw@mail.gmail.com> <mailman.81.1467687507.2295.python-list@python.org> <577b2af3$0$1611$c3e8da3$5496439d@news.astraweb.com> |
| Xref | csiph.com comp.lang.python:111094 |
Show key headers only | View raw
On Tue, Jul 5, 2016 at 1:35 PM, Steven D'Aprano <steve@pearwood.info> wrote: >> If you push your code into a separate .py file, you can reference the >> original module by importing it. Is that also the normal way to use >> "outer" functions etc from inside a namespace? > > Good question! > > With the current implementation, importing should work, but it's not > necessary. The surrounding module (the real .py module) is inserted into > the name resolution path of functions: > > py> x = 999 > py> @namespace.Namespace > ... class Test: > ... def test(): > ... print(x) > ... > py> Test.test() > 999 Ah, fascinating. This does break the "just unindent and move to a new file if you want to break it out" equivalency, but it does make sense - it's a *nested* namespace, which modules (even in a package) are not. So you have the outer namespace acting pretty much the way builtins do. (Do nested namespaces work?) ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Namespaces are one honking great idea Steven D'Aprano <steve@pearwood.info> - 2016-07-02 00:13 +1000
Re: Namespaces are one honking great idea Random832 <random832@fastmail.com> - 2016-07-01 10:40 -0400
Re: Namespaces are one honking great idea BartC <bc@freeuk.com> - 2016-07-01 15:49 +0100
Re: Namespaces are one honking great idea Chris Angelico <rosuav@gmail.com> - 2016-07-02 03:13 +1000
Re: Namespaces are one honking great idea Steven D'Aprano <steve@pearwood.info> - 2016-07-02 03:46 +1000
Re: Namespaces are one honking great idea Rustom Mody <rustompmody@gmail.com> - 2016-07-01 19:26 -0700
Re: Namespaces are one honking great idea Ethan Furman <ethan@stoneleaf.us> - 2016-07-01 09:00 -0700
Re: Namespaces are one honking great idea Steven D'Aprano <steve@pearwood.info> - 2016-07-02 03:10 +1000
Re: Namespaces are one honking great idea Ethan Furman <ethan@stoneleaf.us> - 2016-07-01 12:29 -0700
Re: Namespaces are one honking great idea Steven D'Aprano <steve@pearwood.info> - 2016-07-02 11:07 +1000
Re: Namespaces are one honking great idea Kevin Conway <kevinjacobconway@gmail.com> - 2016-07-02 01:50 +0000
Re: Namespaces are one honking great idea Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-01 19:55 -0700
Re: Namespaces are one honking great idea Steven D'Aprano <steve@pearwood.info> - 2016-07-03 13:22 +1000
Re: Namespaces are one honking great idea Random832 <random832@fastmail.com> - 2016-07-02 00:59 -0400
Re: Namespaces are one honking great idea Kevin Conway <kevinjacobconway@gmail.com> - 2016-07-02 15:34 +0000
Re: Namespaces are one honking great idea Steven D'Aprano <steve@pearwood.info> - 2016-07-03 13:44 +1000
Re: Namespaces are one honking great idea Ethan Furman <ethan@stoneleaf.us> - 2016-07-02 22:14 -0700
Re: Namespaces are one honking great idea Kevin Conway <kevinjacobconway@gmail.com> - 2016-07-03 22:02 +0000
Re: Namespaces are one honking great idea Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-03 16:21 -0700
Re: Namespaces are one honking great idea BartC <bc@freeuk.com> - 2016-07-04 01:19 +0100
Re: Namespaces are one honking great idea Ethan Furman <ethan@stoneleaf.us> - 2016-07-03 21:01 -0700
Re: Namespaces are one honking great idea Ethan Furman <ethan@stoneleaf.us> - 2016-07-02 16:28 -0700
Re: Namespaces are one honking great idea Chris Angelico <rosuav@gmail.com> - 2016-07-04 21:37 +1000
Re: Namespaces are one honking great idea Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-04 15:09 -0700
Re: Namespaces are one honking great idea Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-04 15:11 -0700
Re: Namespaces are one honking great idea jmp <jeanmichel@sequans.com> - 2016-07-04 17:58 +0200
Re: Namespaces are one honking great idea Chris Angelico <rosuav@gmail.com> - 2016-07-05 12:58 +1000
Re: Namespaces are one honking great idea Steven D'Aprano <steve@pearwood.info> - 2016-07-05 13:35 +1000
Re: Namespaces are one honking great idea Chris Angelico <rosuav@gmail.com> - 2016-07-05 13:47 +1000
Re: Namespaces are one honking great idea Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-07-05 16:09 +1000
A nestedmodule decorator (Re: Namespaces are one honking great idea) Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-07-05 21:10 +1200
Improved nestedmodule decorator implementation Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-07-05 21:31 +1200
Re: Improved nestedmodule decorator implementation Steven D'Aprano <steve@pearwood.info> - 2016-07-05 20:54 +1000
Re: Namespaces are one honking great idea Steven D'Aprano <steve@pearwood.info> - 2016-07-05 12:34 +1000
Re: Namespaces are one honking great idea jmp <jeanmichel@sequans.com> - 2016-07-04 13:23 +0200
Re: Namespaces are one honking great idea carlosjosepita@gmail.com - 2016-07-09 07:05 -0700
csiph-web