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


Groups > comp.lang.python > #61580

Re: load_module for import entire package

From Dave Angel <davea@davea.name>
Subject Re: load_module for import entire package
Date 2013-12-11 10:05 -0500
References <cbf4a2a0-82d9-4f4f-9b1c-c6baa36b1aee@googlegroups.com> <cbf4a2a0-82d9-4f4f-9b1c-c6baa36b1aee@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.3901.1386774277.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, 10 Dec 2013 23:28:31 -0800 (PST), Sergey <sh0375@gmail.com> 
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

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


Thread

load_module for import entire package Sergey <sh0375@gmail.com> - 2013-12-10 23:28 -0800
  Re: load_module for import entire package Dave Angel <davea@davea.name> - 2013-12-11 10:05 -0500
  Re: load_module for import entire package alex23 <wuwei23@gmail.com> - 2013-12-12 16:58 +1000
    Re: load_module for import entire package Sergey <sh0375@gmail.com> - 2013-12-12 23:09 -0800

csiph-web