Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #92904

Re: instance as module

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'report.': 0.07; 'imported': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'defer': 0.16; 'dictionary.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:instance': 0.16; 'widely': 0.18; 'project,': 0.18; 'purposes': 0.20; 'trying': 0.22; 'of.': 0.22; 'recognize': 0.22; 'bit': 0.23; 'module': 0.23; 'replacing': 0.23; 'slightly': 0.23; 'import': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.26; 'skip:" 20': 0.26; 'actual': 0.29; "i'm": 0.29; 'looks': 0.29; 'allows': 0.30; 'similar': 0.32; 'related': 0.32; 'problem': 0.33; 'behind': 0.35; 'to:addr:python-list': 0.35; 'something': 0.35; 'but': 0.36; 'modules': 0.36; 'quite': 0.37; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'rather': 0.38; 'received:org': 0.38; 'names': 0.38; 'things': 0.39; 'to:addr:python.org': 0.39; 'received:de': 0.40; 'learn': 0.60; 'your': 0.60; 'received:217': 0.61; 'different': 0.64; 'accessed': 0.66; 'overcome': 0.72; 'special': 0.72; 'accessed.': 0.84; 'becker': 0.84; 'safe.': 0.93; 'technique': 0.93; 'approached': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From dieter <dieter@handshake.de>
Subject Re: instance as module
Date Sat, 20 Jun 2015 08:10:34 +0200
References <5583E0EA.2090309@chamonix.reportlab.co.uk>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Gmane-NNTP-Posting-Host pd9e0a69b.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
Cancel-Lock sha1:JjEuwD4CKtCYduEaY7Lj9c1s53E=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.655.1434780646.13271.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1434780646 news.xs4all.nl 2867 [2001:888:2000:d::a6]:41908
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:92904

Show key headers only | View raw


Robin Becker <robin@reportlab.com> writes:

> I'm trying to overcome a recursive import issue in reportlab.
> ... sketched solution ...

In the "zope" project, the same problem was approached in a slightly different
way -- see the product "zope.deferredimport". It allows to defer
an actual import for an imported name until this name is accessed.

Looking a bit deeper, I recognize that behind the scenes,
"zope.deferredimport" uses a technique similar to yours:
it replaces the original module by a proxy - which almost behaves
like the original module but has the additional capacity to do special things
for accessed to names not yet in the modules dictionary.

"zope.deferredproxy" is widely used in "zope" projects and I have not
seen any related problem report. Looks as its implementation technique
is rather safe.


You might be able to use "zope.deferredimport" directly for your purposes
or look at its implementation to learn what things the implementors
have taken care of. Or you might just learn from it, that replacing
a module by something similar is quite safe.

Dieter

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: instance as module dieter <dieter@handshake.de> - 2015-06-20 08:10 +0200

csiph-web