← Back to context

Comment by js2

12 hours ago

> That definitely doesn't seem to me like how that should be designed, magically silently importing everything you see and overriding basic functionality.

Modern Python supports various options, notably `-I` (isolated) and `-P` (`PYTHONSAFEPATH`, implied by `-I`) to help with this. But neither prevent shadowing. For a robust solution, you should typically structure your code into packages and use absolute imports. Here's a decent primer on the topic:

https://www.py4u.org/blog/python-problem-with-local-modules-...

edit: `-I` is mentioned in TFA.