There are several classifications of python class attributes
This article mainly introduces several categories of python attributes, which are very detailed and have certain reference value. Friends who are interested must finish reading them.
Description
1. Built-in class properties. There are various built-in properties in the Python class. For example, _ dict_,_doc_,_name_ and so on.
To give the same example, I want to look at all the key-value pairs of employee1. Therefore, you can simply write the following statement that contains the class namespace:
2. User-defined attributes: attributes are created in the class definition. You can dynamically create new properties for an existing instance of a class.
Property can also be bound to the class name.
Are the public, protected, and private attributes, respectively.
Example
Class MyClass: def func (self): print ('Hello') # create a new MyClassob = MyClass () ob.func ()
Give a quick browse, the object is mainly to see everything around you. For example, dogs are the object of animals, and I am the object of human beings. Similarly, the same phone class can have different objects. This is very similar to the function calls we discussed. Let's understand this with an example:
These are all the contents of this article entitled "there are several categories of python attributes". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!