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


Groups > comp.lang.python > #26663

Re: find out whether a module exists (without importing it)

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <miki.tebeka@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'argument': 0.04; "'.'": 0.09; 'hierarchical': 0.09; 'subject:module': 0.09; 'to:addr:comp.lang.python': 0.09; 'url:github': 0.09; 'cc:addr :python-list': 0.10; '"this': 0.13; 'dotted': 0.16; 'from:addr:miki.tebeka': 0.16; 'from:name:miki tebeka': 0.16; 'recipe': 0.16; 'subject:exists': 0.16; 'load': 0.19; 'module': 0.19; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'function': 0.30; 'url:python': 0.32; 'docs': 0.33; 'handle': 0.33; 'received:google.com': 0.34; 'path': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; "didn't": 0.36; 'subject: (': 0.36; 'possible': 0.37; 'itself': 0.37; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'apply': 0.39; 'containing': 0.61; 'say:': 0.84; 'subject:find': 0.84; 'url:imp': 0.84
Newsgroups comp.lang.python
Date Mon, 6 Aug 2012 14:58:24 -0700 (PDT)
In-Reply-To <mailman.3030.1344286110.4697.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=75.82.8.111; posting-account=uo-8fwoAAACKsFzFX78JHudx1V7WDXZ0
References <mailman.3030.1344286110.4697.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 75.82.8.111
MIME-Version 1.0
Subject Re: find out whether a module exists (without importing it)
From Miki Tebeka <miki.tebeka@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.3034.1344290308.4697.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1344290308 news.xs4all.nl 6858 [2001:888:2000:d::a6]:47546
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:26663

Show key headers only | View raw


> imp.find_module(), but
> it didn't find any module name containing a '.'
The docs (http://docs.python.org/library/imp.html#imp.find_module) clearly say:

"This function does not handle hierarchical module names (names containing dots). In order to find P.M, that is, submodule M of package P, use find_module() and load_module() to find and load package P, and then use find_module() with the path argument set to P.__path__. When P itself has a dotted name, apply this recipe recursively."

See https://gist.github.com/3278829 for possible implementation.

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


Thread

find out whether a module exists (without importing it) Gelonida N <gelonida@gmail.com> - 2012-08-06 22:48 +0200
  Re: find out whether a module exists (without importing it) Miki Tebeka <miki.tebeka@gmail.com> - 2012-08-06 14:58 -0700
  Re: find out whether a module exists (without importing it) Miki Tebeka <miki.tebeka@gmail.com> - 2012-08-06 14:58 -0700
    Re: find out whether a module exists (without importing it) Gelonida N <gelonida@gmail.com> - 2012-08-07 00:40 +0200

csiph-web