This article is reproduced, purely for the convenience of the back of their own view, suggest or read the original: http://www.cnblogs.com/dolphin0520/archive/2013/03/29/2986924.htmlFirst, let's talk about class properties and instance propertiesIn
Overview:
An instance method is a method that an instance of a class can use.
A static method is a normal function that is in the namespace defined by the class and does not operate on any instance type. Use the adorner @staticmethod to
static method:A simple function that meets the following requirements:1. nested in the class. 2. There is no self parameter. features :1. Class calls, instance calls, and static methods do not accept automatic self parameters.2. The information for
Instance variable
Instance variables are declared in a class, but outside of methods, construction methods, and statement blocks;
When an object is instantiated, the value of each instance variable is then determined;
Instance
Note: The Python2.7 is used.
One, instance method
An instance method is a method that an instance of a class can use. As follows:
Copy Code code as follows:
Class Foo:
def __init__ (self, name):
Self.name = Name
def hi (self):
class instance methods, private methods, and abstract methodsThe most common use in Python is the class instance method, similar to the class instance property in the attribute, and the same method as the private property, that is, the private
———————————————————————————————————————————
Class method
① class Method:
+ The beginning of the method (defined as the process form and the object method, just the + start, which is the only difference)
The invocation of the class
Add function ios7cook directory for class through Method
The method is the building block of the class. For example, a person class can have such features as walking logic, breathing, eating, and drinking water. These features are typically
Instance variable
Instance variables are declared in a class, but outside of methods, construction methods, and statement blocks;
When an object is instantiated, the value of each instance variable is then determined;
Instance
Python class instance method, class method, class static method,
The following class definition is used as an example:
# Coding: utf-8class A: count = 0 def _ init _ (self, inst_name): self. inst_name = inst_name self. _ class __. count + = 1 def
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.