konradhalas / dacite

Simple creation of data classes from dictionaries.
MIT License
1.76k stars 106 forks source link

apply to dict/list values #139

Closed majiang closed 3 years ago

majiang commented 3 years ago

Is there shorthands for these?:

d: dict
{
    key: dacite.from_dict(data_class=MyDataClass, data=value)
    for (key, value)
    in d.items()
}

l: list
[
    dacite.from_dict(data_class=MyDataClass, data=elem)
    for elem
    in l
]
konradhalas commented 3 years ago

Hi @majiang - no, we don't have such shortcuts and I don't think we should have such things in this library. Your solution looks good and it's very "pythonic".