Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81993
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.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.023 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'initialize': 0.07; 'oh,': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'caching': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'func():': 0.16; 'likewise': 0.16; 'new:': 0.16; 'subject: \n ': 0.16; 'subject:bound': 0.16; 'wrote:': 0.18; 'dependent': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'math': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply- To:1': 0.27; 'idea': 0.28; 'point': 0.28; 'function': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'subject:About': 0.31; 'subject:what': 0.31; 'this.': 0.32; 'fri,': 0.33; 'could': 0.34; 'subject: (': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'scheme': 0.36; 'so,': 0.37; 'pm,': 0.38; 'skip:u 10': 0.60; 'strictly': 0.61; 'happen': 0.63; 'our': 0.64; 'subject:The': 0.64; 'different': 0.65; 'guaranteed': 0.75; 'subject:gets': 0.84; 'to:none': 0.92; 'serious': 0.97 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=b+jJKx5en5TDQhDpt/vFg0Kho+EpSYHiGBf0tjlRWYQ=; b=Lvejq+B2qya3OupdfZn0rIBQwzOM0km10bXco9WFYh8mu/dv3wQBSEuzW6drRHdLYy /vxE5XgTXX7EEy8FfghDieE9ud/KsrnY9HfYqkJbBslzz6rvsPhjn7tlffxxQ+T7eiaD DumY0/6tM2dDRxlGaN64kzz3WSo/ksy5UdFw4Gud4xuZE89mXd+Iyeo+yJdZmkvk2SR6 SSzr/ljE8SR2PbT4PY33CIXpZKY5c/Z15C9R7B48P6oh3/Mk/A7f8GK/KKrsXOeG/gTz +gsXzV8rQbTJd/a94t8WQLhm9J0H5/qszuMSXRVgZquCjXfWenK2HwtiVAYRTNC76+GA VG7Q== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.62.104 with SMTP id x8mr1679421igr.2.1417773784407; Fri, 05 Dec 2014 02:03:04 -0800 (PST) |
| In-Reply-To | <548180ae$0$13007$c3e8da3$5496439d@news.astraweb.com> |
| References | <aa74bd64-0e11-492d-ae2a-4b032a0408f9@googlegroups.com> <548113f3$0$13003$c3e8da3$5496439d@news.astraweb.com> <mailman.16608.1417757783.18130.python-list@python.org> <548180ae$0$13007$c3e8da3$5496439d@news.astraweb.com> |
| Date | Fri, 5 Dec 2014 21:03:04 +1100 |
| Subject | Re: The binding operator, and what gets bound to what (was: About Modifying Globals) |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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 | <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16619.1417773792.18130.python-list@python.org> (permalink) |
| Lines | 34 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1417773792 news.xs4all.nl 2957 [2001:888:2000:d::a6]:41717 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:81993 |
Show key headers only | View raw
On Fri, Dec 5, 2014 at 8:53 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Oh, I learned something new: strictly speaking, this is implementation-
> dependent and not guaranteed to work in the future!
>
> def func():
> global math
> import math
When would you actually *want* this, though? Given that 'import'
already caches, there's not much point caching globally, and the idea
that a function could cause a module-level import to happen is pretty
weird!
The only scheme I could concoct would be something like this:
def use_foo():
global useme
import foo as useme
# code to initialize foo for our use
def use_bar():
global useme
import bar as useme
# likewise
def do_stuff():
useme.blah(1,2,3,4)
So, for instance, if you need a JavaScript executor, you might support
several different runtimes, and allow one to be selected like this.
But this would be serious code smell.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
About Modifying Globals LJ <luisjosenovoa@gmail.com> - 2014-12-04 12:09 -0800
Re: About Modifying Globals Chris Angelico <rosuav@gmail.com> - 2014-12-05 07:22 +1100
Re: About Modifying Globals Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-04 13:21 -0700
Re: About Modifying Globals Dave Angel <davea@davea.name> - 2014-12-04 18:54 -0500
Re: About Modifying Globals Chris Angelico <rosuav@gmail.com> - 2014-12-05 10:58 +1100
Re: About Modifying Globals Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-05 13:09 +1100
The binding operator, and what gets bound to what (was: About Modifying Globals) Ben Finney <ben+python@benfinney.id.au> - 2014-12-05 16:36 +1100
Re: The binding operator, and what gets bound to what (was: About Modifying Globals) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-05 20:53 +1100
Re: The binding operator, and what gets bound to what (was: About Modifying Globals) Chris Angelico <rosuav@gmail.com> - 2014-12-05 21:03 +1100
Re: The binding operator, and what gets bound to what (was: About Modifying Globals) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-05 23:26 +1100
Re: The binding operator, and what gets bound to what (was: About Modifying Globals) Chris Angelico <rosuav@gmail.com> - 2014-12-05 23:42 +1100
Re: The binding operator, and what gets bound to what Ned Batchelder <ned@nedbatchelder.com> - 2014-12-05 07:06 -0500
Re: The binding operator, and what gets bound to what Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-05 23:34 +1100
Re: The binding operator, and what gets bound to what Chris Angelico <rosuav@gmail.com> - 2014-12-05 23:48 +1100
Re: The binding operator, and what gets bound to what Ned Batchelder <ned@nedbatchelder.com> - 2014-12-05 07:56 -0500
Re: About Modifying Globals "shiyao.ma" <i@introo.me> - 2014-12-05 10:53 +0800
csiph-web