Saturday, 24 April 2021

Is this long python typing declaration correct and are there shorter, valid declaration?

I come across a long typing declaration in python 3.7.

name_list: List[Dict[str, Union[str, Any]]] = [
    {"name": "name1", "endDate": "", "character": "good"         
    },
   ]

The typing declaration List[Dict[str, Union[str, Any]]] looks long and inefficient. Is it correct in the first place and what does it mean exactly? Are there shorter ways to make the typing declaration in this context? For example, is List[Dict] just as valid?



from Is this long python typing declaration correct and are there shorter, valid declaration?

No comments:

Post a Comment