2

In PEP 8, Guido said that Python classes should be capitalized for everything but builtin classes:

Note that there is a separate convention for builtin names: most builtin names are single words (or two words run together), with the CapWords convention used only for exception names and builtin constants.

I'm curious: why are some builtin classes in CapWords and others not? For example, classes in the datetime modules (datetime, date, timedelta, etc.) are not capitalized. However, Request (in urllib) and Queue are.

Is there a reason or story behind this?

Temuz
  • 1,413
  • 4
  • 14
  • 23
  • 3
    My money is on "no good reason, just history". –  Feb 06 '14 at 23:26
  • 2
    Expanding on what @delnan said, with different styles used for builtins vs. other classes there's bound to be a conflict when a previously separate module becomes a builtin. – Mark Ransom Feb 06 '14 at 23:46
  • I'm wondering if this is related to them having been/being C extension types. For example I've heard that classes in `datetime` module are C extension types and I know that they are immutable. They may behave unexpectedly if subclassed: https://stackoverflow.com/questions/399022/why-cant-i-subclass-datetime-date – AXO May 25 '17 at 23:31

0 Answers0