Skip to main content

Python package that replicates the R package called 'here'.

Project description

Here

Python package that replicates the R package called "here".

Overview

The here package provides utility functions to determine the root directory of your project and easily resolve paths relative to it. This is particularly useful for managing file paths when calling the code from shells that cd to other directories before executing the script.

With here in R, you never ever have to deal with setwd junk. With here in Python, you never ever have to deal with hard-coding full filepaths or working directory junk.

With both, you can define file paths *relative to the file that calls here() and it will always work!

Features

  • Determine the directory of the current file.
  • Resolve paths relative to the root directory.
  • Supports usage in Jupyter notebooks, .py scripts, and interactive Python shells.

Installation

You can install the package using pip:

pip install --upgrade here

Example Usage

# Get the file working directory
file_working_directory = get_file_working_directory()
print(f"File working directory: {file_working_directory}")
>>> "/Users/michaelboerman/Code/here/here"

# Resolve a relative path using the here function
resolved_path = here("data/output")
print(f"Resolved path: {resolved_path}")
>>> "/Users/michaelboerman/Code/here/data/output"

It works on both .py and .ipynb files!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

here-1.4.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

here-1.4.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file here-1.4.1.tar.gz.

File metadata

  • Download URL: here-1.4.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for here-1.4.1.tar.gz
Algorithm Hash digest
SHA256 b969dc174d6879061699ff903ec37a63cddbfd07e2b74107bc7ef13449c65e23
MD5 4d4ba7a7fe7d0eb89f4fde67ec874de0
BLAKE2b-256 bd05cc1de4b16a2ad0444c27283b6266b92dcfa271b2690b32ea6d6bc795e675

See more details on using hashes here.

Provenance

The following attestation bundles were made for here-1.4.1.tar.gz:

Publisher: python-publish.yml on michaelboerman/here

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file here-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: here-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for here-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b1b24da7657b86a8a4fbbe40e68710e3a7950867ba52c7a1b8d6ea890a00ad3
MD5 4eede020c92d945d9f1e1054b79d9766
BLAKE2b-256 3299ec8a150569902ea0eb915d64c5b8f8f40c3679963e4f615066a34e36dc2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for here-1.4.1-py3-none-any.whl:

Publisher: python-publish.yml on michaelboerman/here

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page