What is the naming convention for Python class references

前端 未结 3 553
忘掉有多难
忘掉有多难 2021-02-03 19:22

What is the naming convention for a variable referencing a class in Python?

class MyClass(object):
    pass

# which one is correct?
reference_to_class = MyClass
         


        
3条回答
  •  清歌不尽
    2021-02-03 20:00

    I treat it the same as an instance variable, which PEP8 defines as using lowercase_underscore_style. (lowercase, with words separated by underscores as necessary to improve readability.)

    http://www.python.org/dev/peps/pep-0008/#id34

提交回复
热议问题