Should Python class filenames also be camelCased?

前端 未结 4 1526
别那么骄傲
别那么骄傲 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:57

    There is a difference in the naming convention of the class name and the file that contains this class. This missunderstanding might come from languages like java where it is common to have one file per class.

    In python you can have several classes per modul (a simple .py file). The classes in this module/file should be called according to the class naming convention: Class names should normally use the CapWords convention. The file containing this classes should follow the modul naming convention: Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability.

    => CamelCase should in the file camelcase.py (or camel_case.py if neccessary)

提交回复
热议问题