A question related to the PYTHONPATH

Ian Kelly ian.g.kelly at gmail.com
Mon Mar 26 15:36:04 EDT 2018


On Mon, Mar 26, 2018 at 1:24 PM, Dan Stromberg <drsalists at gmail.com> wrote:
> On Sun, Mar 25, 2018 at 11:10 PM, dieter <dieter at handshake.de> wrote:
>> adrien oyono <adrienoyono at gmail.com> writes:
>>> I have recently read the documentation about how imports work on python,
>>> and I was wondering why, when you execute a python file, the current
>>> directory is not added by default to the PYTHONPATH ?
>>
>> Maybe, to avoid surprises?
>>
>> You can invoke a script from different positions in your file system.
>> If PYTHONPATH would automatically get ".", the script's behaviour
>> could depend on the position from where it is called.
>
> IINM, this also has security implications.

It's curious then that the -m invocation does add the current
directory, since it's normally used for running standard library
scripts like timeit or venv.



More information about the Python-list mailing list