If the convention in Python is to capitalize classes, why then is list() not capitalized? Is it not a class?

前端 未结 5 1476
耶瑟儿~
耶瑟儿~ 2020-12-08 15:17

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 {

5条回答
  •  时光说笑
    2020-12-08 15:58

    I think that the only person who really knows the entire answer to your question is the BDFL. Convention outside of the types implemented in C is definitely to use upper-case (as detailed in PEP8). However, it's interesting to note that not all C-level types follow the convention (i.e. Py_True, Py_False) do not. Yes, they're constants at Python-level, but they're all PyTypeObjects. I'd be curious to know if that's the only distinction and, hence, the difference in convention.

提交回复
热议问题