How to quickly generate annotation documents with python
Today I will tell you a simple small detail that you only need to pay attention to, you can easily generate annotation documents, and you can also check whether the reference names of the class methods we wrote are repeated or have problems, etc. When you look at the documentation written by other professional experts, you will be envious. Don’t worry, we can let Python generate basically satisfactory documentation for us. Firstly, it can improve the overall readability of the code. Secondly, we can see the overall structure of the code. It is also clearer, which can save a lot of trouble during handover. When other colleagues take over your work, they will not ask you line by line what this is and what it is, because the comments have been expressed very intuitively, and in the integration Sometimes it can be used as a description document to give brief instructions to customers (mainly for your BOSS). Then let’s get to the point of how to implement it. See my simple code format below. Note that the comment place and function name and class name are all related to __all__.
#!/usr/bin/env python # -*-coding:utf-8 -*- ''' 文档快速生成注释的方法介绍,首先我们要用到__all__属性 在Py中使用为导出__all__中的所有类、函数、变量成员等 在模块使用__all__属性可避免相互引用时命名冲突 ''' __all__ = ['Login', 'check', 'Shop', 'upDateIt', 'findIt', 'deleteIt', 'createIt'] class Login: ''' 测试注释一可以写上此类的作用说明等 例如此方法用来写登录 ''' def __init__(self): ''' 初始化你要的参数说明 那么登录可能要用到 用户名username 密码password ''' pass def check(self): ''' 协商你要实现的功能说明 功能也有很多例如验证 判断语句,验证码之类的 ''' pass class Shop: ''' 商品类所包含的属性及方法 update改/更新 find查找 delete删除 create添加 ''' def __init__(self): ''' 初始化商品的价格、日期、分类等 ''' pass def upDateIt(self): ''' 用来更新商品信息 ''' pass def findIt(self): ''' 查找商品信息 ''' pass def deleteIt(self): ''' 删除过期下架商品信息 ''' pass def createIt(self): ''' 创建新商品及上架信息 ''' pass if __name__=="__main__": import pythonzhushi print help(pythonzhushi)
I would like to emphasize that the name of py must be the same as the name of the py you are currently working on (the name of the py I created here is pythonzhushi, and the final import is also this name), because in the following test, the import imports itself, so , the import name, Help (name) and your file name must be consistent. In order to be more intuitive, please look at the picture below:
Of course, you can also import from other files. Here we use the common import method of Python from which directory to import what files to import pythonzhushi
Of course I still use pictures here. Show the following:
Is it clear at a glance? In this way, we can also import the annotation documents we need to do. The help method is to help us view a simple help document for the classes and functions contained in this file, similar to the readme A description of the document. Finally, let’s take a look at the masking effect:
Is it possible to simply print out the description document of our program? In the following steps, you can directly create a text and paste this over to complete a readme document description. After testing A few points to note are that if you want to write a comment like #, don't write it inside the def. It should be written above it, similar to the decorator. On the contrary, don't write the three quotation marks ''' outside the def. This will have no display effect. . Everyone, hurry up and try it. thanks for watching. .

Python and C each have their own advantages, and the choice should be based on project requirements. 1) Python is suitable for rapid development and data processing due to its concise syntax and dynamic typing. 2)C is suitable for high performance and system programming due to its static typing and manual memory management.

Choosing Python or C depends on project requirements: 1) If you need rapid development, data processing and prototype design, choose Python; 2) If you need high performance, low latency and close hardware control, choose C.

By investing 2 hours of Python learning every day, you can effectively improve your programming skills. 1. Learn new knowledge: read documents or watch tutorials. 2. Practice: Write code and complete exercises. 3. Review: Consolidate the content you have learned. 4. Project practice: Apply what you have learned in actual projects. Such a structured learning plan can help you systematically master Python and achieve career goals.

Methods to learn Python efficiently within two hours include: 1. Review the basic knowledge and ensure that you are familiar with Python installation and basic syntax; 2. Understand the core concepts of Python, such as variables, lists, functions, etc.; 3. Master basic and advanced usage by using examples; 4. Learn common errors and debugging techniques; 5. Apply performance optimization and best practices, such as using list comprehensions and following the PEP8 style guide.

Python is suitable for beginners and data science, and C is suitable for system programming and game development. 1. Python is simple and easy to use, suitable for data science and web development. 2.C provides high performance and control, suitable for game development and system programming. The choice should be based on project needs and personal interests.

Python is more suitable for data science and rapid development, while C is more suitable for high performance and system programming. 1. Python syntax is concise and easy to learn, suitable for data processing and scientific computing. 2.C has complex syntax but excellent performance and is often used in game development and system programming.

It is feasible to invest two hours a day to learn Python. 1. Learn new knowledge: Learn new concepts in one hour, such as lists and dictionaries. 2. Practice and exercises: Use one hour to perform programming exercises, such as writing small programs. Through reasonable planning and perseverance, you can master the core concepts of Python in a short time.

Python is easier to learn and use, while C is more powerful but complex. 1. Python syntax is concise and suitable for beginners. Dynamic typing and automatic memory management make it easy to use, but may cause runtime errors. 2.C provides low-level control and advanced features, suitable for high-performance applications, but has a high learning threshold and requires manual memory and type safety management.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software