skip to navigation
skip to content

Not Logged In

current 0.2

Current module relative paths and imports

Latest PyPI Version License Downloads

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

$ 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)

Changelog

Version 0.2: Added caller_path.

Version 0.1: First public release.

 
File Type Py Version Uploaded on Size
current-0.2.zip (md5) Source 2014-01-22 4KB
  • Downloads (All Versions):
  • 34 downloads in the last day
  • 200 downloads in the last week
  • 512 downloads in the last month