[issue33547] Relative imports do not replace local variables

2018-05-24 Thread Rolf Campbell
Rolf Campbell added the comment: Is there any way to use relative imports and explicitly request a sub-module? >From PEP 328: "import <> is always absolute" So it sounds like there is no way to duplicate the explicit request for a sub-module when usi

[issue33547] Relative imports do not replace local variables

2018-05-23 Thread Rolf Campbell
Rolf Campbell added the comment: OK, while I understand what you are saying, that is NOT how absolute imports work. I'll give an example: ./main.py:import func ./main.py:print(f"Value of func.func after import func:{func.func}") ./main.py:import func.func ./main.py:print(f&quo

[issue33547] Relative imports do not replace local variables

2018-05-18 Thread Rolf Campbell
Rolf Campbell added the comment: OK, OK, I think I finally understand what you mean here. Let me try to repeat it just to make sure I really understand: When requesting a member of a multi-file module (like "func" in my example), python only tries to load that member as a module

[issue33547] Relative imports do not replace local variables

2018-05-18 Thread Rolf Campbell
Change by Rolf Campbell : -- resolution: not a bug -> ___ Python tracker <https://bugs.python.org/issue33547> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue33547] Relative imports do not replace local variables

2018-05-18 Thread Rolf Campbell
Rolf Campbell added the comment: Re-opening because I've found a simple example that does not involve __main__. ./func/__init__.py:func = 1 ./func/__init__.py:from . import func ./func/__init__.py:print(f"Namespace value of func after func module import:{func}") ./func/func.p

[issue33547] Relative imports do not replace local variables

2018-05-17 Thread Rolf Campbell
Rolf Campbell added the comment: Thanks David, I agree that my assumption that the local valiables were not being replaced is not really what was going on there. I also agree that, while this might not strictly classify as a bug, it's probably not the most helpful/useful way that

[issue33547] Relative imports do not replace local variables

2018-05-16 Thread Rolf Campbell
Rolf Campbell added the comment: Under simple circumstances, this is only reproducible when either directly in an interactive Python session (or as -c), but I encountered this type of problem in a much more complicated project which was NOT running as part of an interactive Python session

[issue33547] Relative imports do not replace local variables

2018-05-16 Thread Rolf Campbell
New submission from Rolf Campbell : Relative imports do not replace local variables, but also don't fail. This can cause some very strange outcomes like this simple example: touch a.py; python3.6 -c 'a=7; b=5; from . import a as b; print(a,b)' I would expect this to produce &q