Sorry if I'm belabouring the point, I should have included this in my last e-mail. But you seem to be saying that when I write import xyz and I mean "import xyz from the current directory, not from the stdlib [or whatever]" I have to know the names of all the modules in the stdlib [or whatever]. Or else *always* add some boilerplate whenever I mean "import from the current directory". Well, maybe, but I am sure a lot of the time I couldn't be bothered, and then some day I'd run into a not-immediately-obvious bug. I.e.: Changing the current behaviour would surprise me. Rob Cliffe
On 08/03/2016 00:06, Chris Angelico wrote:
On Tue, Mar 8, 2016 at 10:48 AM, Rob Cliffe rob.cliffe@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 _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/