且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python:术语“类"VS“类型"

更新时间:2022-12-22 22:35:27

它或多或少是历史性的:很久以前它们曾经是不同的,现在已经没有实际意义了.

It is more or less historical: they used to be different a long time ago, which has no practical implications anymore.

我在提到具体实现时使用class",而在谈到高级别数据结构、应用程序架构等.在我的想法中,类型是一种更一般的东西,我不认为每个类都是不同的类型.

I use "class" when referring to concrete implementations and "type" in a more informal way, when speaking about high level data structures, application arcitecture etc. In my thinking a type is a more general thing, I don't think of every class as a distinct type.

此外,当我使用元类(很少)时,我会提到类型.

Also, when I use metaclasses (very rarely) I speak of types.