how to check if a module is importable?

R

Robert P. J. Day

finally getting back to clawing my way thru the python 3 book so
probably a number of newbie questions coming up. first one -- can i
check if a module is importable (equivalently, exists on sys.path, i
assume) without trying to import it first?

i can see that i can use try/except and just run "import" -- is that
the accepted way to test?

rday
--

========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
========================================================================
 
L

Lie Ryan

finally getting back to clawing my way thru the python 3 book so
probably a number of newbie questions coming up. first one -- can i
check if a module is importable (equivalently, exists on sys.path, i
assume) without trying to import it first?

i can see that i can use try/except and just run "import" -- is that
the accepted way to test?

check imp.find_module()
 
R

Robert P. J. Day

check imp.find_module()

thanks, that's what i was looking for. i'm sure i'll run across
that shortly as i keep working my way thru this python 3 book.

rday
--

========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
========================================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top