What is the naming convention for Python class references

前端 未结 3 550
忘掉有多难
忘掉有多难 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:10

    On module level the second:

    ReferenceToClass = MyClass

    As a function argument, the first:

    reference_to_class = MyClass

提交回复
热议问题