Armin Rigo wrote: > import neatTricks in "/home/guido/lib/python" # no package > import package.module in "/home/guido/lib/python" # package > import foo in "." # relative import > from neatTricks in "../cmds" import a, b, c > s=os.path.join("some", "where"); import foo in s # expression path > >where the semantics would be to search sys.path if and only if no 'in' clause >is specified. ('in' doesn't sound quite right...) > Armin - Thinking about the semantics of the above, including corner cases, I find myself wanting to make the semantics of: <some_kind_of_import_statement> in "<path>" to be equivalent to: sys.path.insert(0, "<path>") <some_kind_of_import_statement> del sys.path[0] # assuming the import doesn't modify sys.path That doesn't seem to be quite equivalent to what you've proposed. On the other hand, that seems to provide at least semi-reasonable answers to questions about what happens to sys.modules, what happens if sys.modules['package'] is defined when importing package.module, what's the correct search path when a module being imported does an import, etc. Having said that, that makes me feel negatively about the proposal, since you could do it yourself directly. Chris
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