How do you PEP 8-name a class whose name is an acronym?

后端 未结 8 785
抹茶落季
抹茶落季 2020-12-05 04:08

I try to adhere to the style guide for Python code (also known as PEP 8). Accordingly, the preferred way to name a class is using CamelCase:

Almost wi

8条回答
  •  [愿得一人]
    2020-12-05 04:36

    PEP-8 does cover this (at least partially):

    Note: When using abbreviations in CapWords, capitalize all the letters of the abbreviation. Thus HTTPServerError is better than HttpServerError.

    Which I would read to mean that NASAJPL() is the recommended name according to PEP-8.

    Personally I'd find NasaJpl() the easiest to scan since the upper case letters easily mark word boundaries and give the name a distinctive shape.

提交回复
热议问题