Often when I see class definitions class Foo:
, I always see them start with upper case letters.
However, isn\'t a list []
or a dict {
Yes, uppercase-initial classes are the convention, as outlined in PEP 8.
You are correct that many builtin types do not follow this convention. These are holdovers from earlier stages of Python when there was a much bigger difference between user-defined classes and builtin types. However, it still seems that builtin or extension types written in C are more likely to have lowercase names (e.g., numpy.array
, not numpy.Array
).
Nonetheless, the convention is to use uppercase-initial for your own classes in Python code.