[Python-ideas] My objections to implicit package directories
p.f.moore at gmail.com
Tue Mar 13 20:24:23 CET 2012
On 13 March 2012 15:57, Guido van Rossum <guido at python.org> wrote:
> Oh, but there are several other solutions. For example, if you set
> PYTHONPATH to the directory *containing* your toplevel package, new
> code could be added that will discover the true toplevel no matter
> where you are. This code doesn't exist today, but Nick is proposing
> something similar looking for __init__.py files; the code that tries
> to find the script directory as a subdirectory of some path on
> sys.path could be added there. Also, the code Nick currently proposes
> for PEP 395 is still useful if you add __init__.py files to your
> package -- if you did that you wouldn't have to set PYTHONPATH
> (assuming we do add this code to Python 3.3, of course).
I tend not to use PYTHONPATH - I'm on Windows, and environment
variables aren't the obvious solution there so I tend to forget. Also,
I tend to initially develop projects in subdirectories of my "junk"
directory, which has all sorts of cruft in it, including .py files
with random names. So setting PYTHONPATH to that could introduce all
sorts to my namespace, which is a bit less than ideal.
OTOH, I don't have a problem with __init__.py files, so something that
correctly autodetects the right thing to add to sys.path based on the
presence of __init__ files would be fine.
All of which assumes that me simply being more organised isn't the
real answer here :-)
More information about the Python-ideas