skip to navigation
skip to content

Not Logged In

current 0.3.1

Current module relative paths and imports

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.

Installation

This package runs under Python 2.7 and 3.3+, 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.

Changelog

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.

 
File Type Py Version Uploaded on Size
current-0.3.1-py2.py3-none-any.whl (md5) Python Wheel 2.7 2014-05-11 4KB
current-0.3.1.zip (md5) Source 2014-05-11 7KB
  • Downloads (All Versions):
  • 24 downloads in the last day
  • 93 downloads in the last week
  • 367 downloads in the last month