Should Python class filenames also be camelCased?

前端 未结 4 1551
别那么骄傲
别那么骄傲 2021-02-02 05:10

I know that classes in Python are typically cased using camelCase.

Is it also the normal convention to have the file that contains the class also be camelCase\'d especia

4条回答
  •  眼角桃花
    2021-02-02 05:43

    The following answer is largely sourced from this answer.

    If you're going to follow PEP 8, you should stick to all-lowercase names, with optional underscores.

    To quote PEP 8's naming conventions for packages & modules:

    Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability.

    And for classes:

    Class names should normally use the CapWords convention.

    See this answer for the difference between a module, class and package:

    A Python module is simply a Python source file, which can expose classes, functions and global variables.

提交回复
热议问题