Python programs and relative imports

Rob Gaddi rgaddi at highlandtechnology.invalid
Fri Apr 8 12:59:59 EDT 2016


Rob Gaddi wrote:

> Does anyone know the history of why relative imports are only available
> for packages and not for "programs"?  It certainly complicates life.
>

Really, no one?  It seems like a fairly obvious thing to have included;
all of the reasons that you want to be explicit in saying:

  from . import mypkg

in a package apply just as well in an executable script.  But instead,
they've got different semantics such that you expressly _cannot_ use
relative imports in a script.  This feels like such a glaring oversight
that there must have been some rationale behind it.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.



More information about the Python-list mailing list