[Python-ideas] Pseudo-package for current directory
Chris Angelico
rosuav at gmail.com
Mon Mar 7 19:06:26 EST 2016
On Tue, Mar 8, 2016 at 10:48 AM, Rob Cliffe <rob.cliffe at btinternet.com> wrote:
> On 07/03/2016 16:54, Chris Angelico wrote:
>>
>> "import html" shouldn't ever import from the
>> current directory.
>>
>>
> I don't agree.
> When troubleshooting, you may wish to dig into packages (in the stdlib, or
> 3rd-party packages) to find out what is going on, and run your own version
> with (say) diagnostic messages added.
> I am sure I have done this a few times. Sorry, I can't give chapter and
> verse.
In the unusual cases where you actually want that, there are other
solutions. You could either change the code to say "from . import
html", or spin up a virtual environment and edit the actual code in
html.py. Or you could explicitly add a directory to PYTHONPATH for
your overrides (~/monkeypatch/html.py or something). The default
import mechanism doesn't need to handle overrides IMO.
ChrisA
More information about the Python-ideas
mailing list