I think I agree with Serhiy, but I don't think Anders' suggestion is workable since it's very common in __init__.py to do exactly this (import * from local modules in order to re-export them), and you definitely don't want to explitly foo=foo for everything. That's the whole reason you "import *". For example, https://github.com/numpy/numpy/blob/master/numpy/linalg/__init__.py Best, Neil On Friday, July 26, 2019 at 2:53:23 PM UTC-4, Anders Hovmöller wrote:
On 26 Jul 2019, at 20:34, Serhiy Storchaka <stor...@gmail.com <javascript:>> wrote:
26.07.19 21:10, Anders Hovmöller пише:
This doesn't really solve the problem imo. Imported symbols shouldn't be i portable elsewhere. Not by import * or explicitly. That's the problem.
I do not think that this is always a problem. It is common to refactor the code by defining names in submodules and then importing them in the main module. For example, in `json/__init__.py`:
from .decoder import JSONDecoder, JSONDecodeError from .encoder import JSONEncoder
It is possible even to use a star import.
So this change would break much more code.
I believe I covered that in my last email. I'll repeat it here for clarity: if you indent to re-export you can do that explicitly:
from foo import bar bar = bar
For "from x import *" you'd need to iterate over __import_dict__ (or whatever we call it) and set them all.
/ Anders
_______________________________________________ Python-ideas mailing list -- python...@python.org <javascript:> To unsubscribe send an email to python-id...@python.org <javascript:> https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EP3PK3... Code of Conduct: http://python.org/psf/codeofconduct/