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):
Print Self.name
if __name__ = = ' __main__ ':foo01 = Foo (' Letian ')Foo01.hi ()Print type (Foo)Print type (FOO01)Print ID (foo01)Print ID (Foo)
The results of the operation are:
Copy Code code as follows:
Letian
4012470
Echo (CLS):Print Cls.valif __name__ = = ' __main__ ':Foo.echo ()Operation Result:Copy CodeThe code is as follows:3Vi. How to call the constructor of a parent classSubclasses (derived classes) do not automatically invoke the Init method of the parent class (the base class), for example:Copy CodeThe code is as follows:Class Foo (object):def __init__ (self):Self.val = 1Class Foo2 (Foo):def __init__ (self):Print Self.valif __name__ = = ' __main__ ':Foo2 = Foo2 ()Run the Times wrong.There are two ty
PHP Static latency static binding usage analysis, Static static
This article describes the usage of Static binding with PHP Static latency. We will share this with you for your referen
Static keyword memory analysis and static keyword Analysis
Generally, Java divides memory into stack memory, heap memory, and method areas. stack memory is used to store some basic types of variables and arrays (arrays are also a reference type) and object reference variables, and the heap memory is mainly used to plac
Js object-oriented static method and static property instance analysis, js instance analysis
This article describes the js object-oriented static methods and static attributes. Share it with you for your reference. The specific
Python implementation class static variable usage instance, python static
This article describes the usage of static variables in python classes. Share it with you for your reference. The specific
() obj.out () output result: OutoutStatic methods allow us to execute methods in a class without having to create an object.V. Types of methodsA class method is a way to manipulate the class itself as an object. The difference between him and the static method is that whether this is called from an instance or from a class, it uses the first parameter to pass the class over . classFoo:annimal='Cat' def __init__(self):Pass defShow (self):Print('
. Since it is a mathematical operation, there is no need to instantiate this class, if this method can be used for more convenient.
This is just the class designed to demonstrate the static method. The max () function comparison value is provided in PHP.
How static methods Call static methods
The first example, when a
Python basics-encapsulation and extension, static methods and class methods, python static
I. encapsulation and Expansion
Encapsulation is to clearly distinguish the inside and outside, so that the class implementers can modify the content in the encapsulation without affecting the code of the external caller.External
A brief analysis of the usage difference between static and non-static methods in PHP
In PHP programming, the Static keyword declares that a property or method is related to a class and not to a particular instance of a class, so that such a property or method is also known as a class property or class method
If the a
In this paper, the static and Non-static methods of C # are analyzed, and their usage is analyzed comprehensively. Share to everyone for your reference. The specific analysis is as follows:
In general, C # classes can contain two methods: static methods and Non-static metho
Detailed description of PHP static binding Analysis and Application in later stages, detailed description of php static binding
Basic knowledge
1. Range Resolution operator (::)
It can be used to access static members, class constants, and overwrite attributes and methods in the class.
The three special keywords s
Analysis of the difference between static class and static variable usage in PHP
Static is the definition of a static object or a static variable, and what are the characteristics of a variable or class method that is defined by
The difference between static class and static variable usage in PHP, PHP variable
This paper analyzes the difference between static class and static variable usage in PHP. Share to everyone for your reference. The specific analysis is as follows:
This article mainly introduces C # static and non-static methods, focuses on the practical application of static methods, and helps to further deepen the understanding of C # program design, you can refer to the examples in this article to analyze the C # static and non-static
thinkphp Static cache usage analysis, thinkphp static cache
In this paper, the static cache usage of thinkphp is analyzed in detail. Share to everyone for your reference. The specific analysis is as follows:
Thinkphp has a built-in stat
Excerpt from: http://www.oschina.net/question/129540_23043 analysis and comparison of common Java static code analysis toolsIntroduction: This article first introduced the static Code Analysis basic concept and the main technology, then introduced the existing 4 kinds of mai
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.