One, PackagePackageHides the properties and implementation details of an object, providing public access only to the outside.Benefits1. Isolate the changes;2. easy to use;3. Improve reusability;4. Improve safety;"Encapsulation principle"1. Hide the
1.classChinese:country=' China' def __init__(self,name): Self.name=namedefPlay_ball (self,ball):Print('%s is playing%s'%(Self.name,ball)) P1=chinese ("North Sir")Print(P1.country)#This is the data property of the class
1. Usage Scenarios(1) The calling process is cumbersome and requires encapsulation(2) Call parameters need to be processed encapsulation(3) need to add additional functions, such as log, cache, operation record, etc.2. Code
A, Member: 1. Fields: Static fields (each object has the same field), Normal dictionary (each object has different data) 2. Methods: Static methods (without using the object's contents), class methods, common methods (using data in objects)
Instance_eval method
This basicobject#instance_eval is somewhat similar to the Bind method in JS, when bind is passed this into the object, and Instance_eval is the block of code (context probes Probe) Passed in to the specified object, one for the
First, the package#面向对象: EncapsulationClass Person: def __init__ (self,name,age): """ constructor, which is executed automatically when the class is called. Can be used to encapsulate a variety of common parameters and so on.
1. The meaning of object-oriented programming, can Baidu2. Classes: Class compared to the real world is a kind, a model.3. Instantiation: The process of making a model into something real is called instantiation.4. Instance/object: something that is
1. Start executing the App.run () in manage.py firstdef run (self, host=none, Port=none, Debug=none, * *options) : fromimport Run_simple try: #Run_simple is a Werkzeug provided method that executes the third argument self ()
1. Mode OneA subclass invokes a method of a parent class that contains a call in the form of 2. One form is to invoke the method of the parent class within the class through inheritance, and the other is to invoke the method of the parent class by
The @ Overview TK is a (available for multi-platform) GUI library; Tkinter is the interface of the Python language to access the library and the standard for Python's GUI development;
@ First GUI interface
From tkinter Import *
# Create a program
Clearsilver's Chinese documents are not on a few books, so the English version of the official website has been translated by one. I have limited ability, if there are mistakes, I would like to enlighten. Original address: http://www.clearsilver.net/
To sum up the problems I encountered in the actual process, please read the python tutorial and Python FAQ first.
1. If the encapsulated C ++What if the class does not copy the constructor?When defining the class, add the template parameter boost:
This note is used to help understand the "The ruby language allows us to define classes based on an object so that we can expand the behavior of an object separately. The example is as follows:Test = "hello" # normal string
Normal = A. DUP # normal
I recently read the source code of saltstack, understand the process, and view the execution process of the salt command. Think about whether you can transform the source code, so you need it. Later I thought about whether I could specify the jid
Observer Pattern
Observer mode: Also known as the Publish subscription mode, defines a one-to-many dependency, allowing multiple observer objects to listen to a Subject object at the same time, when the state of the subject changes, it notifies all
Queue module keeps thread synchronizedUsing the Queue object's FIFO feature, each producer's data is saved to the queue one at a time, and each consumer pulls the data from the queue sequentially
Import Threading # Imports Threading Module Import
Python class inheritanceI. Overview
One of the main functions of Object-Oriented Programming (OOP) is "inheritance ". Inheritance refers to the ability to use all the functions of an existing class and extend these functions without re-writing the
This is a self-made exercise and may be incorrect. You are welcome to discuss and discuss various optimization and reconstruction solutions.Based on feedback or code review, the updated answers or related content of this article will be added to the
I have made some optimizations on the memory usage of the program recently, and have achieved good results. I have summarized some experiences.
I believe it will be helpful for you to write high-quality programs.
The following discussion is not
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.