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


Groups > comp.lang.python > #26665

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

From Miki Tebeka <miki.tebeka@gmail.com>
Newsgroups comp.lang.python
Subject Re: find out whether a module exists (without importing it)
Date 2012-08-06 14:58 -0700
Organization http://groups.google.com
Message-ID <062c08b7-a1d8-4858-b123-9a812804af0f@googlegroups.com> (permalink)
References <mailman.3030.1344286110.4697.python-list@python.org>

Show all headers | 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