Mart Somermaa wrote: > I meant that you have to > >>>> import sys > > only to access sys.modules (i.e. importing sys may not be necessary otherwise). I understand that, but I'm arguing that that's a non-problem. Importing sys is a regular thing in Python, not an exception. You need sys to get to sys.argv, sys.exit, sys.stdout, etc. -- it's not like sys is an infrequently used module. Since sys is always present, importing it is not an efficiency problem, either. >>>> mod = __import__(modname, submodule=True) > > with > >>>> import sys >>>> __import__(modname) >>>> mod = sys.modules[modname] "import sys" is normally located near the beginning of the file (and needed by other things), so the actual code snippet would really contain only those two lines, which don't strike me as bad. Ideally, __import__ would simply return the "tail" imported module in the first place, but I don't think introducing a boolean keyword argument really improves the design.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4