At present, the development of naming conventions are basically followed by the hump nomenclature, such as: UserName. I'm not going to have the specs, and we all know it. Then get to the point, how to get a good name in Python, so you can better see the name of the idea?
1. Tuple (tuple) type variable name
In Python, a tuple type variable, such as: Schoolroles = ("Student", "Class monitor", "teacher", "schoolmaster"), we can correspond to an array in Java.
Recommendation: The Tuple type variable is named as "variable name +s" or "Variable name +tuple".
2. List type variable name
In Python, the list type variable: such as: Studentlist = ["Zhangsan", "Lisi", "Wangwu"], which is similar to the list in Java.
Recommendation: The List type variable is named "Variable name +list".
3. Dictionary (Dictionary) type variable name
Dict type variables in python: studentdict = {"Name": "Zhangsan", "Age": "+", "Sex": "Male"}, which is similar to JSON data format.
Recommendation: The Dict type variable is named "Variable name +dict".
4. Set (set) type variable name
In Python, a set type variable is similar to a set in Java as a sequence of unordered, non-repeating elements.
Recommendation: The Set type variable is named in the form of variable name + Set.
To apply a tuple or dict in a 5.List or set
For example: Studenttuplelist = [("Zhangsan", "Lisi", "Wangwu"), ("Liubei", "Guanyu", "Zhangfei")],
Studentdictlist = [{"Name": "Zhangsan", "Age": "+", "Sex": "Male"},{"name": "Lisi", "Age": "A", "Sex": "Male"}]
Set the list.
Recommendation: When a tuple or dict is applied in a list or set, it is named "Variable name +tuple or Dict+list or set".
Summary: The simple type ends with the type name, and the complex list or collection type ends with type name +list or set, so that we can better understand the meaning of the variable name and the stored information and how it is stored when using Python.
The above is a number of personal suggestions, if there is any better advice please feedback, we learn from each other.
Python Usage Tips-variable naming