Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:module': 0.04; 'function:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:don': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'pypi.': 0.16; 'stephane': 0.16; 'subject:import': 0.16; '\xe9crit': 0.16; 'blog:': 0.22; 'header:In-Reply-To:1': 0.22; 'tue,': 0.23; 'import': 0.29; 'module': 0.30; 'thanks': 0.31; 'hi,': 0.31; 'to:addr:python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'header:User-Agent:1': 0.34; 'subject: ?': 0.35; 'some': 0.37; 'received:org': 0.38; 'subject:can': 0.38; 'subject:: ': 0.38; 'eric': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'subject:but': 0.67; 'subject:this': 0.74; 'url:info': 0.75; 'from:charset:windows-1252': 0.84; 'snow': 0.91; 'subject:found': 0.91; 'klein': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: =?windows-1252?Q?St=E9phane_Klein?= Subject: =?windows-1252?Q?Re=3A_imp=2Efind=5Fmodule_don=27t_found_?= =?windows-1252?Q?my_module_but_standard_import_statement_can?= =?windows-1252?Q?_import_this_module=85_why_=3F?= Date: Tue, 05 Jul 2011 15:47:11 +0200 References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: pda57-1-82-231-115-1.fbx.proxad.net User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110627 Thunderbird/5.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1309873646 news.xs4all.nl 21793 [2001:888:2000:d::a6]:56202 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8824 Le 05/07/2011 15:44, Eric Snow a écrit : > On Tue, Jul 5, 2011 at 1:36 AM, Stéphane Klein wrote: >> Hi, >> >> I would like import some module dynamically. >> > > To import a module dynamically, you can use the built-in __import__ function: > > module = __import__("js") > > Even better, use importlib's import_module, which is available in > 2.7/3.2. A backport is available on PyPI. > > module = importlib.import_module("js") > Thanks ! It's work very well. Regards, Stephane -- Stéphane Klein blog: http://stephane-klein.info Twitter: http://twitter.com/klein_stephane pro: http://www.is-webdesign.com