Get the path of a file relative to the current module. Import a Python module relative to the current module. Temporarily change sys.path for imports. Get the path of a file relative to the module of the current caller.
Links
GitHub: https://github.com/xflr6/current
Issue Tracker: https://github.com/xflr6/current/issues
Download: https://pypi.org/project/current/#files
Installation
This package runs under Python 3.10+, use pip to install:
$ pip install current
Usage
Get paths relative to the current module:
>>> import current
>>> here = current.current_path()
>>> parent = current.current_path('..')
>>> bruces = current.current_path('..', 'australia', 'bruces', 'bruces.ini')
Temporarily add the parent directory to sys.path:
>>> with current.inserted_path()
... import australia
Get paths relative to the module of the callers of the current code:
>>> caller = current.caller_path()
>>> callercaller = current.caller_path(steps=2)
Potential issues
This package uses sys._getframe (which is almost the same as inspect.currentframe, see docs). Under IronPython this might require enabling the FullFrames option of the interpreter.
License
Changelog
Version 0.5: Drop Python 3.7, 3.8, and 3.9 support; tag Python 3.11, 3.12, 3.13, and 3.14 support. Switch to pyproject.toml and mark package as py.typed (PEP 561 compliant).
Version 0.4.1: Drop Python 3.6 support.
Version 0.4: Drop Python 2 and 3.5 support; tag Python 3.9 and 3.10 support.
Version 0.3.6: Tag Python 3.8 support. Extend test coverage.
Version 0.3.5: Drop Python 3.4 support.
Version 0.3.4: Tag Python 3.7 support.
Version 0.3.3: Drop Python 3.3 support. Add python_requires.
Version 0.3.2: Port tests from nose/unittest to pytest. Update meta data, tag Python 3.5/3.6 support.
Version 0.3.1: Added wheel.
Version 0.3: Added Python 3.3+ support.
Version 0.2.1: Fixed caller_path. Documented sys._getframe dependency.
Version 0.2: Added caller_path.
Version 0.1: First public release.
Release files for current 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| current-0.5.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| current-0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.0 kB
Release files / current-0.5.tar.gz
| Download URL | current-0.5.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
38317aa5386dcb76728f2334efb4d303b24be59210ed9059a40da2f0bea6db4e
|
|
BLAKE2b-256 checksum How to use checksums |
bfd2243ffcdc4c984b5fb184f76d9de526144e7b8b0bfcb3b5862058f000749f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.8
|
Release files / current-0.5-py3-none-any.whl
| Download URL | current-0.5-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da971a95fdd62d38191587a76f9605e12ac682c190dcc9d5331d462798cedf0d
|
|
BLAKE2b-256 checksum How to use checksums |
68f9f4501ba15e376d3a7852ec78d444edac3f82438b72c76670ca0097285125
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.8
|