Sriram Krishna <ksr...@gmail.com> added the comment:

My contention is that this behaviour breaks the Principle of Least Astonishment.

In the particular example I gave, the user doesn't know (and can't be expected 
to know) the existence of a module called profile in the standard library. Here 
the user is not explicitly importing profile. The user can't be expected to 
know which submodules are imported by the modules they use. Hence they wouldn't 
expect another file sitting in the same directory to get imported when they are 
not explicitly importing it.

on 2018-12-02 10:35, pmpp said:
> you can avoid that with

> import sys,os
> sys.path.remove( os.getcwd() )

> at the start of your program. 

completely removing cwd from sys.path would disable the option of importing 
user modules.

Any method of fixing this would be backwards incompatible, and will break some 
(most likely badly written) code.

My hack solution was to have cwd in sys.path only if __name__ is '__main__'.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35375>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to