Message80987
| Author |
mrts |
| Recipients |
brett.cannon, hauser, mrts |
| Date |
2009年02月02日.20:01:29 |
| SpamBayes Score |
1.0038542e-06 |
| Marked as misclassified |
No |
| Message-id |
<1233604891.49.0.796777609967.issue2090@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
A pointer for people who keep referring to this bug -- after
discussions, the following idiom was selected as the "official" way to
import modules by name in 2.x (as seen in latest 2.x docs
http://docs.python.org/dev/library/functions.html#__import__ ).
---
If you simply want to import a module (potentially within a package) by
name, you can get it from sys.modules:
>>> import sys
>>> name = 'foo.bar.baz'
>>> __import__(name)
<module 'foo' from ...>
>>> baz = sys.modules[name]
>>> baz
<module 'foo.bar.baz' from ...> |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2009年02月02日 20:01:31 | mrts | set | recipients:
+ mrts, brett.cannon, hauser |
| 2009年02月02日 20:01:31 | mrts | set | messageid: <1233604891.49.0.796777609967.issue2090@psf.upfronthosting.co.za> |
| 2009年02月02日 20:01:30 | mrts | link | issue2090 messages |
| 2009年02月02日 20:01:29 | mrts | create |
|