đŸ•ˇī¸ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 84 (from laksa067)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

â„šī¸ Skipped - page is already crawled

📄
INDEXABLE
✅
CRAWLED
2 months ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH2.4 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/pep-328.html
Last Crawled2026-01-26 19:16:34 (2 months ago)
First Indexed2017-10-01 19:52:42 (8 years ago)
HTTP Status Code200
Meta Title4 PEP 328: Absolute and Relative Imports
Meta Descriptionnull
Meta Canonicalnull
Boilerpipe Text
The simpler part of PEP 328 was implemented in Python 2.4: parentheses could now be used to enclose the names imported from a module using the from ... import ... statement, making it easier to import many different names. The more complicated part has been implemented in Python 2.5: importing a module can be specified to use absolute or package-relative imports. The plan is to move toward making absolute imports the default in future versions of Python. Let's say you have a package directory like this: pkg/ pkg/__init__.py pkg/main.py pkg/string.py This defines a package named pkg containing the pkg.main and pkg.string submodules. Consider the code in the main.py module. What happens if it executes the statement import string ? In Python 2.4 and earlier, it will first look in the package's directory to perform a relative import, finds pkg/string.py , imports the contents of that file as the pkg.string module, and that module is bound to the name " string " in the pkg.main module's namespace. That's fine if pkg.string was what you wanted. But what if you wanted Python's standard string module? There's no clean way to ignore pkg.string and look for the standard module; generally you had to look at the contents of sys.modules , which is slightly unclean. Holger Krekel's py.std package provides a tidier way to perform imports from the standard library, import py ; py.std.string.join() , but that package isn't available on all Python installations. Reading code which relies on relative imports is also less clear, because a reader may be confused about which module, string or pkg.string , is intended to be used. Python users soon learned not to duplicate the names of standard library modules in the names of their packages' submodules, but you can't protect against having your submodule's name being used for a new module added in a future version of Python. In Python 2.5, you can switch import 's behaviour to absolute imports using a from __future__ import absolute_import directive. This absolute-import behaviour will become the default in a future version (probably Python 2.7). Once absolute imports are the default, import string will always find the standard library's version. It's suggested that users should begin using absolute imports as much as possible, so it's preferable to begin writing from pkg import string in your code. Relative imports are still possible by adding a leading period to the module name when using the from ... import form: # Import names from pkg.string from .string import name1, name2 # Import pkg.string from . import string This imports the string module relative to the current package, so in pkg.main this will import name1 and name2 from pkg.string . Additional leading periods perform the relative import starting from the parent of the current package. For example, code in the A.B.C module can do: from . import D # Imports A.B.D from .. import E # Imports A.E from ..F import G # Imports A.F.G Leading periods cannot be used with the import modname form of the import statement, only the from ... import form. Release 1.0. See About this document... for information on suggesting changes.
Markdown
| | | | | | | | |---|---|---|---|---|---|---| | [![Previous Page](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/previous.png)](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/pep-314.html "3 pep 314: Metadata") | [![Up one Level](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/up.png)](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/whatsnew25.html "What's new in Python") | [![Next Page](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/next.png)](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/pep-338.html "5 pep 338: Executing") | What's New in Python 2.5 | [![Contents](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/contents.png)](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/contents.html "Table of Contents") | ![](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/blank.png) | ![](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/blank.png) | **Previous:** [3 PEP 314: Metadata](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/pep-314.html) **Up:** [What's New in Python](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/whatsnew25.html) **Next:** [5 PEP 338: Executing](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/pep-338.html) *** # 4 PEP 328: Absolute and Relative Imports The simpler part of PEP 328 was implemented in Python 2.4: parentheses could now be used to enclose the names imported from a module using the `from ... import ...` statement, making it easier to import many different names. The more complicated part has been implemented in Python 2.5: importing a module can be specified to use absolute or package-relative imports. The plan is to move toward making absolute imports the default in future versions of Python. Let's say you have a package directory like this: ``` pkg/ pkg/__init__.py pkg/main.py pkg/string.py ``` This defines a package named pkg containing the pkg.main and pkg.string submodules. Consider the code in the main.py module. What happens if it executes the statement `import string`? In Python 2.4 and earlier, it will first look in the package's directory to perform a relative import, finds pkg/string.py, imports the contents of that file as the pkg.string module, and that module is bound to the name "string" in the pkg.main module's namespace. That's fine if pkg.string was what you wanted. But what if you wanted Python's standard string module? There's no clean way to ignore pkg.string and look for the standard module; generally you had to look at the contents of `sys.modules`, which is slightly unclean. Holger Krekel's py.std package provides a tidier way to perform imports from the standard library, `import py ; py.std.string.join()`, but that package isn't available on all Python installations. Reading code which relies on relative imports is also less clear, because a reader may be confused about which module, string or pkg.string, is intended to be used. Python users soon learned not to duplicate the names of standard library modules in the names of their packages' submodules, but you can't protect against having your submodule's name being used for a new module added in a future version of Python. In Python 2.5, you can switch import's behaviour to absolute imports using a `from __future__ import absolute_import` directive. This absolute-import behaviour will become the default in a future version (probably Python 2.7). Once absolute imports are the default, `import string` will always find the standard library's version. It's suggested that users should begin using absolute imports as much as possible, so it's preferable to begin writing in your code. Relative imports are still possible by adding a leading period to the module name when using the `from ... import` form: ``` # Import names from pkg.string from .string import name1, name2 # Import pkg.string from . import string ``` This imports the string module relative to the current package, so in pkg.main this will import name1 and name2 from pkg.string. Additional leading periods perform the relative import starting from the parent of the current package. For example, code in the A.B.C module can do: ``` from . import D # Imports A.B.D from .. import E # Imports A.E from ..F import G # Imports A.F.G ``` Leading periods cannot be used with the `import modname` form of the import statement, only the `from ... import` form. See Also: [PEP 328, *Imports: Multi-Line and Absolute/Relative*](http://www.python.org/peps/pep-0328.html "Imports: multi-line and Absolute/Relative") PEP written by Aahz; implemented by Thomas Wouters. <http://codespeak.net/py/current/doc/index.html> The py library by Holger Krekel, which contains the py.std package. *** | | | | | | | | |---|---|---|---|---|---|---| | [![Previous Page](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/previous.png)](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/pep-314.html "3 pep 314: Metadata") | [![Up one Level](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/up.png)](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/whatsnew25.html "What's new in Python") | [![Next Page](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/next.png)](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/pep-338.html "5 pep 338: Executing") | What's New in Python 2.5 | [![Contents](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/contents.png)](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/contents.html "Table of Contents") | ![](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/blank.png) | ![](https://edoras.sdsu.edu/doc/Python-Docs-2.5/icons/blank.png) | **Previous:** [3 PEP 314: Metadata](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/pep-314.html) **Up:** [What's New in Python](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/whatsnew25.html) **Next:** [5 PEP 338: Executing](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/pep-338.html) *** Release 1.0. See *[About this document...](https://edoras.sdsu.edu/doc/Python-Docs-2.5/whatsnew/about.html)* for information on suggesting changes.
Readable Markdownnull
Shard84 (laksa)
Root Hash13923086562776807484
Unparsed URLedu,sdsu!edoras,/doc/Python-Docs-2.5/whatsnew/pep-328.html s443