Import a module from a specific file path

Ben Finney ben+python at benfinney.id.au
Sat Nov 22 01:46:11 EST 2014


Chris Angelico <rosuav at gmail.com> writes:

> So can you simply:
>
> $ python -m foo.fooprog
>
> ? (or 'python3', either way)

So, that's a pretty awful user interface. (The file is named ‘fooprog’
because it's an executable, intended to be run directly at the command
line.) That solution would be rather inferior to the program being able
to import modules when invoked as the top-level program.

Can you suggest solutions that allow invoking the program as ‘./fooprog’
to work?

-- 
 \         “In economics, hope and faith coexist with great scientific |
  `\      pretension and also a deep desire for respectability.” —John |
_o__)                                    Kenneth Galbraith, 1970-06-07 |
Ben Finney




More information about the Python-list mailing list