I'm trying to run a python file interactively. The file imports other local modules. E.g., I have foo/bar.py
and foo/baz.py
. I want to run foo/bar.py
interactively, and in foo/bar.py
I have from foo import baz
.
From foo
's parent directory, I can run python -m foo.bar
, and the import of baz works fine. But when I want to run interactively with python -i foo/bar.py
, the import no longer works (the same is true if I do python foo/bar.py
).
Why is that? Can I invoke python differently to get this to work? Am I organizing my code in a strange way?