-
Notifications
You must be signed in to change notification settings - Fork 0
python_general
Marcel Schmalzl edited this page Jan 17, 2025
·
2 revisions
Print the structure of a whole object via pprint.pprint(vars(...))
:
import pprint
# Object to inspect
class PhysicalFunction:
def __init__(self):
self.name = "ExampleFunction"
self.parameters = {
"param1": 10,
"param2": 20,
"param3": [1, 2, 3, 4, 5],
"param4": {"subparam1": "value1", "subparam2": "value2"}
}
self.description = ("This is a detailed description of the ExampleFunction. "
"It includes multiple parameters and nested structures.")
attributes = pprint.pprint(vars(PhysicalFunction()))
Output:
{'description': 'This is a detailed description of the ExampleFunction. It '
'includes multiple parameters and nested structures.',
'name': 'ExampleFunction',
'parameters': {'param1': 10,
'param2': 20,
'param3': [1, 2, 3, 4, 5],
'param4': {'subparam1': 'value1', 'subparam2': 'value2'}}}
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License *.
Code (snippets) are licensed under a MIT License *.
* Unless stated otherwise