zope.dottedname

7.1 · active · verified Thu Apr 16

zope.dottedname is a Python library that provides a single `resolve()` function for converting strings containing Python dotted names (e.g., 'os.path.join') into the corresponding Python object (module, class, function, etc.). It is currently at version 7.1 and is actively maintained by the Zope Foundation, with several releases per year to add new Python version support and address maintenance.

Common errors

Warnings

Install

Imports

Quickstart

The `resolve` function is the core of `zope.dottedname`. It takes a dotted name string and returns the corresponding Python object. It can handle both absolute and relative dotted names, with relative names requiring an additional `relative_to` argument.

from zope.dottedname import resolve

# Resolve an absolute dotted name to a module
math_module = resolve('math')
print(f"Resolved 'math' to: {math_module}")

# Resolve an absolute dotted name to a function within a module
join_function = resolve('os.path.join')
print(f"Resolved 'os.path.join' to: {join_function}")

# Resolve a relative dotted name (e.g., '.split' relative to 'os.path')
split_function = resolve('.split', relative_to='os.path')
print(f"Resolved '.split' relative to 'os.path' to: {split_function}")

# Resolve a relative dotted name across package boundaries ('..system' relative to 'os.path')
system_function = resolve('..system', relative_to='os.path')
print(f"Resolved '..system' relative to 'os.path' to: {system_function}")

view raw JSON →