11 2024 档案

摘要:dst是一个基于go语言实现的,操纵ast的第三方库。 文件解析、修改与写入的一般流程: content, _ := os.ReadFile(root_path) f, _ := decorator.ParseFile(nil, root_path, content, parser.ParseCom 阅读全文
posted @ 2024-11-22 19:48 LRJ313 阅读(94) 评论(0) 推荐(0)
摘要:对类进行索引 翻阅python源码有时会看到类似这样的实现,class Dataset(Generic[T_co]):Generic是一个类,但是可以直接对其进行索引,这需要归功于魔法方法__class_getitem__。 class Box: def __class_getitem__(cls, 阅读全文
posted @ 2024-11-14 22:16 LRJ313 阅读(318) 评论(0) 推荐(0)