Python Foundation ===monkeytype can automatically add comments to the module!

Source: Internet
Author: User
Tags sqlite database stub

Monkeytype A module that can add comments automatically!

To download First:

Pip Install Monkeytype

Take the sample code of the official website as an example

# moudle.py def Add (A, b):     return A + b

This test.py file will call the Add () method

#test. py

fromimport addprint(Add (1, 2))

We execute the following command in the cmd window:

Monkeytype Run test.py

After the program is executed, you can see that 3 is returned.

Ok! The point is that we found a monkeytype.sqlite3 file.

The official website explains this:

By default this would dump call traces to a SQLite database in the "file in the monkeytype.sqlite3 " current working directory. You can then use monkeytype the command to generate a stub file for a module, or apply the type annotations directly to your CO De.

Execute the command under CMD:

Monkeytype stub Some.module

You can see clearly the comments on a and B, and the Add method

To apply comments to your code:

Monkeytype Apply Some.module

Look at the module.py file again:

The code has been automatically annotated.

Detailed operation guide, reference:

http://monkeytype.readthedocs.io/en/latest/index.html#

Python Foundation ===monkeytype can automatically add comments to the module!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.