get_path()

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.

Syntax

planetcnc.get_path()
planetcnc.get_path(str)

Parameters

Parameter Type Description
str string A string representing a relative subpath or filename.

Return Value

Examples

#! /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)

See also

get_path
get_path_exe
get_path_profile
get_path_temp
get_path_working