>
> The biggest difference is that scripts can't do relative imports. So
> here's a counter-proposal: Allow "from . import modulename" to import
> "modulename.py" from the directory that contains the script that
> Python first executed (or, for interactive Python, the current
> directory as Python started).
>

Understanding "script" as a free standing ".py"...

I loved your suggestion because of it's convenience, but I worry it could
be a security hole. I have scripts in ~/bin, in ./bin, and in ./scripts.

And for ./scripts, it would be most useful if `from .. import` was allowed,
so there was no more `import sys; sys.path.insert(0, '.').

I believe the above is addressed on a PEP (which number I don't remember).

The discussion that has followed validates the OP's concern (even if the
originally proposed solution is not right).

It's hard to write scripts in Python that have access to the modules they
intuitively should have access to, without patching (`sys.path.insert(...)`
is awful)

-- 
Juancarlo *Añez*
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/UDG4GRHXQYXR4LYHEHP5EGEQAOECHZZC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to