Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the guidelines for using GitHub in python

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what are the guidelines for the use of GitHub in python". In daily operation, I believe many people have doubts about the guidelines for the use of GitHub in python. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what are the guidelines for the use of GitHub in python?" Next, please follow the editor to study!

Rule number one: the less you type, the better

The less we type, the more time we have to think about issues such as code logic. As shown below, "Good" represents an example of following the rule, and Bad indicates an example of not following the rule.

Rule 2: variable / function mixed naming style

We need to mix naming methods with variables in order to reflect the diversity of naming.

Rule number three: don't write notes

Anyway, the code can be understood, so why write comments? Or, no one reads my code anyway, so why write comments?

Article 4: write notes in your mother tongue

If you violate the third rule, at least you need to write notes in your mother tongue or other language. If your mother tongue is English, then you have violated this rule. Since the vast majority of programming languages are in English, why not comment on them in other languages?

Rule 5: mix different formats as much as possible

Similarly, for the sake of code diversity, we need to mix different formats as much as possible, such as single or double quotes. If their semantics are the same, they should be mixed.

Rule 6: write the code on one line as much as possible

If a series of parameters and methods are implemented together, then the code should also be written together.

Rule 7: keep silent when you find a mistake

When you find something wrong, others don't need to know about it, so you don't need to print out a log or Traceback.

Article 8: extensive use of global variables

The use of global variables is an integral part of globalization.

Article 9: build standby variables

Just in case, we need to create some alternate variables and call them whenever we need them.

Article 10: Type should be used with caution

Generally do not specify variable types or often do type checking, no type is the best type.

Article 11: prepare "Plan B"

You need to prepare some code that doesn't work (unreachable code) that can be used as your "Plan B".

Article 12: the triangular law of nesting

If the code has some nested structures, or indented blank lines, the triangle rule is the most beautiful.

Article 13: mixed indentation

We need to avoid indentation because indentation makes complex code take up more space in the editor. If indentation is necessary, then use a mixed indentation strategy. Of course, this strategy doesn't work in Python because it determines the structure of the code by indenting.

Article 14: do not lock dependencies

Update existing dependencies each time a new library is installed. Why maintain the previous version? we need to keep the third-party code base up-to-date at all times.

Article 15: long functions are better than short functions

Don't split the overall logic of the program into blocks of code, what if IDE suddenly fails and it can't find the necessary files or functions. So it is most stable to write code in a body function and no longer maintain additional function imports or code files.

Ten thousand lines of code in a single file is fine, and so is a thousand lines of code in a single function.

Article 16: code does not need to do specific tests

These tests are usually repetitive and meaningless work.

Article 17: avoid duplicating code as much as possible

Write code the way you want, especially in small teams. After all, this is the "freedom" rule.

Article 18: no README documents are required to build a new project

We can maintain this state for the time being in the early stages of the project.

Article 19: save unnecessary code

In the process of writing code, a lot of test code is often generated. This code is also very important information, so it can not be deleted, at most can only be commented out.

At this point, the study of "what are the guidelines for the use of GitHub in python" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report