Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'class,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runtime': 0.09; 'tmp': 0.09; 'works.': 0.09; 'def': 0.12; 'changes': 0.15; '"from': 0.16; 'disc': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:entire': 0.16; 'subject:import': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; 'header:User-Agent:1': 0.23; 'replace': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'properties': 0.29; 'dec': 0.30; 'code': 0.31; 'getting': 0.31; 'that.': 0.31; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'to:addr:python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'first': 0.61; 'information': 0.63; 'received:myvzw.com': 0.84; 'working,': 0.84; 'defeat': 0.91; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: load_module for import entire package Date: Wed, 11 Dec 2013 10:05:35 -0500 References: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 142.sub-70-208-162.myvzw.com In-Reply-To: User-Agent: Groundhog Newsreader for Android X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386774277 news.xs4all.nl 2951 [2001:888:2000:d::a6]:43136 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61580 On Tue, 10 Dec 2013 23:28:31 -0800 (PST), Sergey wrote: > def get_obj(): > pkg = load_package_strict("tmp", basedir) > from tmp import main > return main.TTT() > It is working, but if package code changes on disc at runtime and I call get_obj again, it returns instance of class, loaded for the first time previously. That's how import works. Once something has been imported, the module information is cached. There are three ways to defeat that, but they're all risky. > How to replace line "from tmp import main" by getting properties of pkg? No clue what you mean by that. -- DaveA