param.parameterized.Parameters.pprint#
- Parameters.pprint(imports: list[str] | None = None, prefix: str = ' ', unknown_value: str = '<?>', qualify: bool = False, separator: str = '') str[source]#
Generate a pretty-printed representation of the object.
This method provides a pretty-printed string representation of the object, which can be evaluated using Python
eval()to reconstruct the object. It is intended for debugging, introspection, or generating reproducible representations ofParameterizedobjects.- Parameters:
imports (list of str, optional) – A list of import statements to include in the generated representation. Defaults to None, meaning no imports are included.
prefix (str, optional) – A string to prepend to each line of the representation for indentation or formatting purposes. Default is a single space (
" ").unknown_value (str, optional) – A placeholder string for values that cannot be determined or represented. Default is
<?>.qualify (bool, optional) – If True, includes fully qualified names (e.g.,
module.Class) in the representation. Default isFalse.separator (str, optional) – A string used to separate elements in the generated representation. Default is an empty string (
"").
- Returns:
A pretty-printed string representation of the object that can be evaluated using
eval().- Return type:
- Raises:
NotImplementedError – If the method is called at the class level instead of an instance of
Parameterized.
Notes
The generated representation assumes the necessary imports are provided for evaluation with
eval().
Examples
>>> import param >>> class MyClass(param.Parameterized): ... a = param.Number(default=10) ... b = param.String(default="hello") >>> instance = MyClass(a=20)
Pretty-print the instance:
>>> instance.param.pprint() 'MyClass(a=20)'
Use
eval()to create an instance:>>> eval(instance.param.pprint()) MyClass(a=20, b='hello', name='MyClass00004')