PyXLL The Python Excel Add-In
  • Product
    • Features
    • Get Started
    • Request Demo
    • Download
  • Pricing
  • Resources
    • Documentation
    • Blog
    • Videos
    • FAQ
    • Learn Python
    • Customer Portal
    • About Us
  • Support
    • Documentation
    • Videos
    • FAQ
    • Contact Us
  • Contact Us
Table of Contents
  • PyXLL Documentation
  • Introduction to PyXLL
  • User Guide
    • Installing PyXLL
    • Configuring PyXLL
      • Python Settings
      • PyXLL Settings
      • License Key
      • Logging
      • Warnings
      • Config Variables
      • Config Functions
      • Environment Variables
      • Startup Script
      • Menu Ordering
      • Shortcuts
      • Default Decorator Parameters
    • Worksheet Functions
    • Macro Functions
    • Real Time Data
    • Cell Formatting
    • Charts and Plotting
    • Custom Task Panes
    • ActiveX Controls
    • Using Pandas in Excel
    • Customizing the Ribbon
    • Context Menu Functions
    • Working with Tables
    • Python as a VBA Replacement
    • Menu Functions
    • Reloading and Rebinding
    • Error Handling
    • Deploying your add-in
    • Workbook Metadata
  • Video Guides and Tutorials
  • API Reference
  • What’s new in PyXLL 5
  • Changelog
Close

Config Functions¶

New in PyXLL 5.11

A few pre-defined functions can be used within the config to simplify some scenarios.

Function calls are made using the same syntax as variable substition, but with arguments added.

A function call is specified using the form %(function arg1, arg2, ...)s. Note the trailing s which is the same as for substituted variables.

The available functions are:

  • abspath

  • dirname

  • basename

  • filename

Functions can be nested, and substitution and environment variables can be used as arguments. For example:

[SECTION]
; Get the directory of the absulte path of some file.
; The environment variable 'USER_OVERRIDE_PATH' can be set, otherwise ./default.txt is used.
abs_dir = %(dirname %(abspath %(USER_OVERRIDE_PATH:./default.txt)s)s)s

abspath¶

Converts a relative path (relative to the config file being parsed) to an absolute path.

Example:

[SECTION]
option = %(abspath ./file.txt)s

dirname¶

Gets the directory component of a path.

Example:

[SECTION]
; option will be set to `C:\path\to`
option = %(dirname C:\path\to\file.txt)s

basename¶

Gets the base name of a path. The base name is the full file name, including any extension.

Combine with filename if the file extension is not required.

Example:

[SECTION]
; option will be set to 'file.txt'
option = %(basename C:\path\to\file.txt)s

filename¶

Strips any file extension from a path and returns only the filename component (including any directory).

Combine with basename if only the file name without any path component is required.

Example:

[SECTION]
; option will be set to 'file'
option = %(filename %(basename C:\path\to\file.txt)s)s
« Config Variables
Environment Variables »
  • Home
  • Product
  • Features
  • Documentation
  • Download
  • Pricing
  • Support
  • Documentation
  • Videos
  • FAQ
  • Learn Python
  • Contact Us
  • About
  • About Us
  • Legal
  • Blog
© Copyright PyXLL Ltd