A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-January/042359.html below:

[Python-Dev] Draft: PEP for imports

[Python-Dev] Draft: PEP for importsChris Reedy chrisandannreedy at comcast.net
Fri Jan 30 18:00:14 EST 2004
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



More information about the Python-Dev mailing list

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