Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21764 > unrolled thread
| Started by | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| First post | 2012-03-16 10:06 -0700 |
| Last post | 2012-03-16 10:06 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: avoid import short-circuiting Ethan Furman <ethan@stoneleaf.us> - 2012-03-16 10:06 -0700
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2012-03-16 10:06 -0700 |
| Subject | Re: avoid import short-circuiting |
| Message-ID | <mailman.727.1331917120.3037.python-list@python.org> |
Andrea Crotti wrote: > I started the following small project: > > https://github.com/AndreaCrotti/import-tree > > because I would like to find out what exactly depends on what at > run-time, using an import hook. > > It works quite well for small examples but the main problem is that once > a module is imported > it's added to sys.modules and then it doesn't go through the import hook > anymore. > > I tried to mess around with sys.modules but it might not be a good idea, > and it leads to easy > infinite loops. > Is there a good way to achieve this? > I guess I could do the loop detection myself, but that should not be too > hard.. I believe sys.modules is a dictionary; you might try replacing it with your own custom dictionary that does whatever when the keys are accessed. ~Ethan~
Back to top | Article view | comp.lang.python
csiph-web