pyufunc.dataclass_from_dict#
- pyufunc.dataclass_from_dict(name, data)#
Creates a dataclass with attributes and values based on the given dictionary. The dataclass will also support dictionary-like access via __getitem__ and __setitem__.
- Parameters:
Example
>>> from pyufunc import dataclass_from_dict >>> data = {'name': 'Alice', 'age': 30, 'city': 'New York'} >>> Person = dataclass_from_dict('Person', data) >>> person = Person() >>> person.name 'Alice' >>> person.age 30 >>> person.city 'New York'
- Returns:
A dataclass with fields and values corresponding to the dictionary.
- Return type:
Type