Association between naming classes and naming their files in python (convention?)

前端 未结 2 1039
执念已碎
执念已碎 2020-12-24 10:38

In python (and some other languages) I have learned, that the name of a class should be written in small letters except for the first letter, which should be a capital lette

2条回答
  •  旧时难觅i
    2020-12-24 11:12

    PEP 8 says:

    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.

    I'll also note that you shouldn't necessarily have on only one class per file. Rather you should include related classes together in the same file. (Of course in some cases, having one class to a file works, but that is not always the case)

提交回复
热议问题