Sta*_*mas 2 python python-typing
我喜欢在项目中创建自己的注释或输入扩展。基本上我喜欢做的是在我的项目中重用类型注释。
因此,我不想输入List[Dict[str, pd.DataFrame]]数百次,而是想将其保存到 python 变量中并以这种方式重用它。自定义注释的种类。
我们怎样才能做到这一点?
我尝试过NewType = List[Dict[str, pd.DataFrame]],但没用。从某种意义上说,自动完成功能不会暗示对象的不同功能/属性。
您可以在此处阅读有关自定义新类型的信息。
from typing import NewType, List, Dict
import pandas as pd
CustomType = NewType('CustomType', List[Dict[str, pd.DataFrame]])
Run Code Online (Sandbox Code Playgroud)