[Python-Dev] importing from files with currently invalid names
skip at pobox.com
Wed Mar 3 15:32:31 EST 2004
I just responded to and closed a bug report which asked why
doesn't work. It got me to thinking, with the import ... as ... form Python
could support importing from non-identifier file names by giving some
variant of the file name as a string literal:
import "report-manager" as report_manager
import "report-manager.py" as report_manager
import "/etc/site/parameters" as report_manager
Is that extra flexibility possibly worthwhile? I know Guido's not keen on
polluting the import statement with path information (the third case), but
the others seem like they might be useful.
Adding this support shouldn't break anything since the language grammar
doesn't currently support string literals as the module name.
More information about the Python-Dev