On Wed, Nov 3, 2021 at 1:39 AM Florian Wetschoreck
<[email protected]> wrote:
> I guess, one potential solution would be to change the import resolution
> order. But of course, this is a breaking change (at least in implicit
> semantics - not sure if it will actually lead to too many real-world problems
> - but probably there will be some) and might only be feasible in a safe way
> in a new major version? (Or even in a minor version but with other flags or
> imports from "the past" instead of "future" that restore the old behavior if
> that is actually important for some users?)
>
Yes, that would be a breaking change. But here's a potential migration
path to consider: Make the script directory into an automatic package.
That way, when you specifically *want* to import a nearby file, you
can write a relative import:
# demo.py
print("Hello, world")
# example.py
from . import demo
I'm not sure what the consequences would be on sys.modules; maybe
they'd be keyed as, eg, __main__.demo ?
ChrisA
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/ZPKMYOAHQORBMJ4UAUSWW357WMTD2U5Z/
Code of Conduct: http://python.org/psf/codeofconduct/