Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26694 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2012-08-07 19:08 +1000 |
| Last post | 2012-08-07 19:08 +1000 |
| 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: find out whether a module exists (without importing it) Chris Angelico <rosuav@gmail.com> - 2012-08-07 19:08 +1000
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-08-07 19:08 +1000 |
| Subject | Re: find out whether a module exists (without importing it) |
| Message-ID | <mailman.3047.1344330491.4697.python-list@python.org> |
On Tue, Aug 7, 2012 at 6:00 PM, Gelonida N <gelonida@gmail.com> wrote: > modulename = 'my.module' > cmd = 'import %s as amodule' > try: > exec(cmd) > print "imported successfully" Someone will doubtless correct me if I'm wrong, but I think you can avoid exec here with: amodule=__import__(modulename) ChrisA
Back to top | Article view | comp.lang.python
csiph-web