Programming language Learning--python (1)

Source: Internet
Author: User

All objects in Python, I think objects in this object and object-oriented programming should be different. Python in variables 1, ' A ', functions, classes, modules are objects, when using the type () function, for the above several objects will return a structure similar to the content of <type ' type ', where a is a defined function, B is the defined class.

>>> Print Type (a)'function'>>>> print type (b) ' Classobj '>>>> print type (1)'int'>

Python is a dynamic type language, where the application is detached from the object (not declaring its type when defining the variable, but applying the variable to the variable name when the value is assigned). The application here refers to the memory address, and the pointer is a bit similar. We use the name to represent the application, the variable name, the function name, the class name, and so on, using the ID () function to see the address value corresponding to the name. The object is the above-mentioned variable (1, ' a ', True), function, class, etc.

  

In Python everything is object, in-memory python should use the same method to manage various objects. An application is used to use an object, and an assignment statement can be seen as a link between an object and an app.

 #   variable, where only one object 1,A/B/C is an application of object 1  a=1< Span style= "color: #000000;" >b  =1c  =a  #   New object 2, at which point A is no longer an application of 1, but 2 of the application  a=2#   def   F ():  Span style= "color: #0000ff;" >print   abc   " f2  =f  #   at this time F becomes an application of the ' a ' object, no longer the application of the above function  f=  a   

Python objects are maintained in memory with an app count, added when applied, and deleted when applied. When the count is 0 o'clock, it is possible to clear the memory occupied by the object. The purge or not is related to the object's contents and the GC settings in Python. A GC is a library of Python related to garbage collection.

Programming language Learning--python (1)

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.