0 Basic python-10.2 Multi-objective assignment and variable naming rules

Source: Internet
Author: User
Tags naming convention

1. Multi-Objective assignment


2. Multi-objective assignment and shared reference

There's no problem with non-mutable objects, but for mutable objects, there's a problem here.


The above example AB is immutable, so when B changes, the object that B points to has been re-created.


Because the list is mutable, AB points together to the same list, so when B changes, a also changes

3. Enhanced Assignment

Enhanced assignment is the use of +=,>= and other operators to assign values, here are two examples


4. Enhanced assignment and shared references

The following example is, the enhanced assignment uses + =, here the enhancement assignment implies in the original place to modify the meaning, everybody needs to notice


The above example can be seen, if you use the + expression, just an object modification, but using + =, two list simultaneously modified

5. Variable naming rules

1) Syntax: underline or character + any number of letters, numbers, or underscores

2) Case-sensitive, a and a are two different variables

3) disable reserved words (specific query Python manual)

Note: The naming convention extends to the name of the filename, and if the file name does not conform to the variable naming rules, an error occurs when importing

Right here, thank you.

------------------------------------------------------------------

Click to jump 0 basic python-Catalogue


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

0 Basic python-10.2 Multi-objective assignment and variable naming rules

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.