[issue35375] name shadowing while a module tries to import another

2018-12-02 Thread Sriram Krishna
Sriram Krishna added the comment: Already covered in issue29929: https://bugs.python.org/issue29929. Thanks xtreak for the link to the message thread. PEP 432 seems to have methods to resolve this. Currently if the code doesn't access to .local, one can use the -I commandline option and use

[issue35375] name shadowing while a module tries to import another

2018-12-02 Thread Sriram Krishna
Sriram Krishna 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 ex

[issue35375] name shadowing while a module tries to import another

2018-12-02 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: > A python user can't be expected to know the name of every possible file in > the Python standard library. Maybe the current working directory should be > removed from sys.path when importing from within another module not in the > same directory.

[issue35375] name shadowing while a module tries to import another

2018-12-02 Thread pmpp
pmpp added the comment: hi you are obsverving that because current working directory is set *first* in sys.path as a commodity you can avoid that with import sys,os sys.path.remove( os.getcwd() ) at the start of your program. otherwise usually it is wise to put user module in a package an

[issue35375] name shadowing while a module tries to import another

2018-12-02 Thread Sriram Krishna
New submission from Sriram Krishna : Suppose I have a file profile.py in the same directory as the file I am running (say test.py) Let the contents of the files be: profile.py: raise Exception test.py: import cProfile now if I run test.py $ python test.py Traceback (most recent call last):