Returns the full path to a file located relative to the Python script's directory. This function uses Python’s global file variable to determine the base path of the currently running Python script.
An optional relative path (or filename) can be provided, which is appended to the base directory path.
planetcnc.get_path() planetcnc.get_path(str)
#! /usr/bin/env python import planetcnc # Retrieve the full path to "PlanetCNC.png" relative to the current Python script's directory. full_path = planetcnc.get_path("PlanetCNC.png") print("Full path:", full_path) # Retrieve the base directory of the Python script. base_path = planetcnc.get_path() print("Script directory:", base_path)