Hi, Sorry about the cross posting. Over the last couple of weeks I described a problem and inconsistency with the way Python imports modules. For more details look at this thread: http://mail.python.org/pipermail/python-list/2001-November/070719.html In short, currently, import allows one to use non-absolute module names for modules that are in the current directory. If a module is not in the same directory, import then looks for modules in sys.path. Consequently, dealing with packages that are re-nested is a pain. Complex package structure also causes problems. I'd like to note that I was also not the only person who suffered from this issue -- four others on mentioned similar problems and some asked me to let them know if I found a solution. Subsequently, I proposed another approach that first looks in the local directory and then walks up the current package tree looking for modules before looking at sys.path. I also modified knee.py to obtain a working solution. More information is here: http://mail.python.org/pipermail/python-list/2001-November/071212.html the threading is messed up and starts here: http://mail.python.org/pipermail/python-list/2001-November/071218.html You can find the new module and a simple test package here: http://av.stanford.edu/~prabhu/download/ There is also a slightly enhanced version of knee.py included that supports caching module lookup failures suggested by Rainer and Gordon in: http://mail.python.org/pipermail/python-list/2001-November/071218.html it also fixes a bug where the parent package is an extension module. I therefore have a working import style that seems to handle importing packages in a more natural(?) and consistent(?) manner. I've also tested it out with a large package like scipy (http://www.scipy.org) with no trouble or significant performance problems: http://mail.python.org/pipermail/python-list/2001-November/071325.html I'd like to ask the Python developers if they'd consider (a) changing the way the current import works to do what I proposed, or, (b) add a new keyword like 'rimport' (or something) that does this recursive search through parent packages and loads modules. This was actually suggested by Gordon McMillan. Gordon actually suggested something stronger -- import only supports absolute names, rimport is relative import and rrimport is a recursive relative import. But this would break the current import since import currently aupports some relative lookup. So maybe import and rimport is a workable solution? (c) patch the existing knee.py with my fixes. Note: these fixes have nothing to do with the recirsive module lookup stuff -- knee.py is merely an improved version of the older one. Thanks for listening patiently and sorry again for all the cross posting. prabhu
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