Python basics-Object-oriented initialization

Source: Internet
Author: User

class:
A class of things with the same attributes and skills.
object:
the specific performance of the class.
class keyword
Class Name: (class name should be capitalized first)
code block.
country = ' China ' first part: Static variable, static field

def __init__ (self,name,age): Part Two: Dynamic methods, functions, methods
Pass
def func (self):
Pass
the structure of the class is divided into two parts.
class Name:
#1, class name. __dict__
#2, class name. Country (class name. __dict__[' Country ') is not recommended and cannot be modified or deleted.
class name. Variable names can be changed or deleted.
#3, class name. Func (111)
object:
obj1 = class name ()
1, in memory created an empty! Object space.
2, automatically executes the __init__ (self), and passes the empty object space
3, in the __init__ method, the empty object space encapsulates some properties, and then the perfect space is returned to the class name (), the object.
# 1, the object looks at all the properties of its own space:
obj.__dict__
# 2, the object operates its own properties. A universal point.
obj. Attribute name (add-and-revise check.)
# 3, an object can query a static field in a class.
obj. static field.
# 4, the object executes the method in the class.
obj. Method name ()

Python basics-Object-oriented initialization

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.