Python – How to Import a Module With Spaces in Its Name
Let’s say I have a module named “Excellent Module.py”
How would I import that into a script since:
import Excellent Module
doesn’t work?
Answer, use:
ExcellentModule = __import__('Excellent Module')
Thanks Farshid.
The real answer is: don’t create modules with spaces in their name.
__import__ doesn’t do what you’d expect for packages.
Yes, yes, Bob. I meant to say “assuming you have a really good reason for having spaces in the name”.