Which abbreviations should we use for python variable names?

后端 未结 5 1147
说谎
说谎 2021-02-08 19:27

In generally I\'m using the standard naming stated in PEP-8 for variables. Like:

delete_projects
connect_server

However sometimes I can\'t find

5条回答
  •  悲&欢浪女
    2021-02-08 19:42

    I think long names are acceptable provided that they are descriptive. With a good editor/IDE, short names cannot save typing, while long but descriptive names can save the time of reading your code. So the length of the reading time of the name is much more important than the actual length of the name.

    As for your example, project_name_to_be_deleted is fine. If you want to shorten it, I will suggest using project_name_to_del since del is a well-known abbreviation for delete (you can even find this in your keyboard). And the use conf as configuration is also popular. But don't go further. For example, proj2del is not a good idea.

    Also, for internal/local things, it's fine to use short-not-so-descriptive names.

提交回复
热议问题