Question about packages
mark at mceahern.com
Tue Dec 30 05:02:40 CET 2003
On Mon, 2003-12-29 at 21:44, djw wrote:
> So, the question is, how do you import into a sub-package to allow both
> a script at the root level to import the module ("library mode") and for
> the module itself to run in "test harness" mode with the same import?
You could do something like:
if __name__ == '__main__':
# Hmm, must be running the test harness, adjust
# sys.path appropriately, then retry import
but that smells.
Maybe it's best to separate tests from code?
More information about the Python-list