赋值 class 的变量是否应该是小写?
Does variable that has assigned class should be a lowercase?
我有这样的案例:
Serializer = get_serializer_class()
到处都找不到答案,serializer应该是小写还是大写?
Class 名称按照 PEP 8 约定大写,但这只是一个变量名(class 的实例)。所以答案是否定的。
PEP 8 指出
Function names should be lowercase, with words separated by underscores as necessary to improve readability.
Variable names follow the same convention as function names.
所以你的问题的答案是否定的。
Class 然而名称:
Class names should normally use the CapWords convention.
我有这样的案例:
Serializer = get_serializer_class()
到处都找不到答案,serializer应该是小写还是大写?
Class 名称按照 PEP 8 约定大写,但这只是一个变量名(class 的实例)。所以答案是否定的。
PEP 8 指出
Function names should be lowercase, with words separated by underscores as necessary to improve readability. Variable names follow the same convention as function names.
所以你的问题的答案是否定的。
Class 然而名称:
Class names should normally use the CapWords convention.