Style Guidance

To ensure the consistency and readability of the code throughout this repository, we have established basic guidelines and standards for developers. This includes recommendations for coding style, naming conventions, and comment. Contributors to this repository are expected to review and adhere to these guidelines.

Coding Style

The code in this repository is written in Python and follows the PEP8 coding style guidelines. We recommend using the black formatter, which strictly adheres to the PEP8 rules when formatting code. More information about black is available on its official website.

To install black, run the command pip install black. Integrated development environments such as Visual Studio Code or JetBrains PyCharm generally support formatting code with black. In the case of Visual Studio Code, add the following code to the configuration file settings.json, enabling black to be used as the default code formatter with hotkey Shift+Alt+F.

Note that in this repository, single quotes are used exclusively for strings ('str' or '''str''')!!! Since black defaults to using double quotes, the -S or --skip-string-normalization argument should be used to prevent automatic conversion of single quotes to double quotes.

Naming Conventions

Common names for variables and functions include:

In general, this repository follows the convention of using underscores to separate words in variable and function names:

In summary, names should be short, descriptive, and easy to understand. In some cases, other naming conventions such as CamelCase or abbreviated names might be accepted for compatibility with third-party libraries.

Comments and DocStrings

Comments are a key element of code readability, helping to reduce the difficulty of reading code for other users and improving the efficiency of code editing, modification, and debugging. Therefore, it is important to add comments at appropriate locations throughout the code, using both block and inline comments. Note that never describe the code. Assume the person reading the code knows Python (though not what you're trying to do) better than you do.

Python has built-in support for DocStrings, which can be used for classes, functions, modules, and packages. DocStrings can be accessed using the __doc__ attribute. The commenting and DocString conventions used in this repository are based on the Google Style Guide. Users can refer to this guide for more specific details.

A simple example of a function DocString is shown below:

A copyright notice should be placed at the top of each file, as shown in the example below, providing information about the encoding format used in the file and a copyright statement.