Should Python class filenames also be camelCased?

前端 未结 4 1492
别那么骄傲
别那么骄傲 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 06:02

    My question is, is it also the normal convention to have the file that contains the class also be camelCase'd especially if the file only contains the class

    Short answer: No.

    Longer answer: should be all lower case and underscores as needed.

    From PEP8 "Package and Module Names":

    Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.

    If you're unclear what a module is:

    A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended.

提交回复
热议问题