sebpiq sebpiq - 1 year ago 56
Python Question

Python : terminology 'class' VS 'type'

Just a simple question : when should I use the term 'class', and when should I use the term 'type' in Python ?

  • is 'class' only for user-defined types, and 'type' for built-in types ?

  • or now that everything is a type ... should I use always 'type' even for user-defined classes ?

  • ... ?


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

Edit: 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.