Python Variable naming conventions

Source: Internet
Author: User

Python source code and some other books, naming a variety of personalities, not a more uniform naming conventions. So I summed up some, for reference.
Module Name:
Lowercase letters, dividing between words with _
ad_stats.py

Package Name:
Same as the module name

Class Name:
Capitalize the first letter of the word
Adstats
Configutil

global variable names (class variables, equivalent to static variables in Java):
Uppercase letters, dividing between words with _
Number
Color_write

Common variables:
Lowercase letters, dividing between words with _
This_is_a_var

Instance variable:
Start with _, the rest is the same as the normal variable
_price
_instance_var

Private instance variable (external access will error):
Starts with __ (2 underscores), and the other is the same as the normal variable
__private_var

Proprietary variables:
__ Begins, __ ends, is usually python's own variable, do not name it in this way
__doc__
__class__

Common functions:
As with normal variables:
Get_name ()
Count_number ()
Ad_stat ()

Private Function (external access will error):
Starts with __ (2 underscores), and the rest is the same as the normal function
__get_name ()

Python Variable naming conventions

Related Article

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.