Is it only possible if I rename the file? Or is there a __module__
variable to the file to define what\'s its name?
When you do import module_name
the Python interpreter looks for a file module_name
.extension
in PYTHONPATH. So there's no chaging that name without changing name of the file. But of course you can do:
import module_name as new_module_name
or even
import module_name.submodule.subsubmodule as short_name
Useful eg. for writing DB code.
import sqlite3 as sql
sql.whatever..
And then to switch eg. sqlite3
to pysqlite
you just change the import line