How can I import a dotted name file in python?
I don't mean a relative path, but a filename starting or containing a dot "."
For example: '.test.py'
is the filename.
import .test
will search for a test
package with a py
module in a parent package.
The situation is tricky, because dots mean subpackage structure to python. Never the less it is still kinda possible with imp
:
import imp
my_module = imp.load_source('my_module', '.test.py')
note: this is unorthodox and you are recommend to simply rename your modules instead.