The first knowledge of Python (2) __python object

Source: Internet
Author: User
Tags scalar

Python Object

Everything in Python is an object, so-called object: I am an object, I play the computer is the object, sitting chair is the object, the home of the puppy is an object ...

We describe an object by describing attributes (characteristics) and behavior. For example, the puppy in the home, its color, size, age, weight, etc. is its properties or characteristics. It will bark, will wag its tail, and so on is its behavior.

We include two aspects when describing a real object (object):

What it can do (behavior)

What it is (attributes or characteristics).

In Python, the characteristics of an object are also known as attributes (attribute). The behavior it has is also called the method.

Conclusion: Object = attribute + method

Object Three features:

    1. Identity: Unique identity flag, which is the memory address of the object, which can be used to obtain the type of the built-in function ID ()
    2. Type: integer, float, character, etc. you can use the built-in function type () to view the type of the Python object, and type () returns an object instead of a simple string. For example:
>>> B = 1>>> type (b)'int'> >>> type (int) ' type '>>>> type'type' >

The type of B is int, and the type of int is ' type ', type or type.

3. Value: The data item represented by the object

Object Properties

attribute : A property that is used to describe the characteristics of a particular object and is static. For example: Yao Ming is more than 2.6 meters tall, small white hair is brown, two lang God has an eye on the forehead;

Standard type

    • Number (divided into sub-types, three of which are integer)
    • Integral type
    • Boolean type
    • Long integer type
    • Floating point Type
    • Plural type
    • String
    • List
    • Meta-group
    • Dictionary

Data type

Storage model

Update model

Access model

Digital

Scalar Atomic Type

Cannot be changed

Direct access

String

Scalar Atomic Type

Cannot be changed

Sequential access

List

Container container

Can be changed

Sequential access

Meta-group

Container container

Cannot be changed

Sequential access

Dictionary

Container container

Can be changed

Map Access

Other types:

    • Type
    • Null object (None)
    • File
    • Set/fixed Set
    • Functions/Methods
    • Module
    • Class

Internal type (tentative initial understanding)

    • Code: Reference: Code objects in Python
    • Frame:
    • Tracking Records
    • Slices: A Slice object is created when the tiling syntax is extended using Python. Extended slice syntax allows for different index slicing operations, including stepping slices, multidimensional slices, and omitting slices. The multidimensional slice syntax is sequence[start1:end1,start2:end2], or use the ellipsis, Sequence[...,start1:end1]. The slice object can also be generated by the built-in function slice (). Step slices allow stepping slices with the third slice element, whose syntax is sequence[start index: End index: Step value]
    • Omitted
    • Xrange

Built-in functions

built-in Functions

ABS ()

Divmod ()

Input ()

Open ()

Staticmethod ()

All ()

Enumerate ()

Int ()

Ord ()

STR ()

Any ()

Eval ()

Isinstance ()

POW ()

SUM ()

Basestring ()

ExecFile ()

Issubclass ()

Print ()

Super ()

Bin ()

File ()

ITER ()

Property ()

Tuple ()

BOOL ()

Filter ()

Len ()

Range ()

Type ()

ByteArray ()

Float ()

List ()

Raw_input ()

UNICHR ()

Callable ()

Format ()

Locals ()

Reduce ()

Unicode ()

Chr ()

Frozenset ()

Long ()

Reload ()

VARs ()

Classmethod ()

GetAttr ()

Map ()

Repr ()

Xrange ()

CMP ()

Globals ()

Max ()

Reversed ()

Zip ()

Compile ()

Hasattr ()

Memoryview ()

Round ()

__import__ ()

Complex ()

Hash ()

Min ()

Set ()

Apply ()

Delattr ()

Help ()

Next ()

SetAttr ()

Buffer ()

Dict ()

Hex ()

Object ()

Slice ()

Coerce ()

Dir ()

ID ()

Oct ()

Sorted ()

Intern ()

Reference official website: built-in Functions

Standard type operators and built-in functions

Operator/function

Description

Result

String

‘‘

String representation

St

CMP (OBJ1, OBJ2)

Compares objects

Inch

Repr (obj)

String representation

St

STR (obj)

String representation

St

Type (obj)

Determines object type

Typ

Value Comparisons

<

Less than

Boo

>

Greater than

Boo

<=

Less than or equal to

Boo

>=

Greater than or equal to

Boo

==

Equal to

Boo

!=

Not equal to

Boo

<>

Not equal to

Boo

Object Comparisons

Is

The same as

Boo

is not

Not the same as

Boo

Boolean operators

Not

Logical negation

Boo

and

Logical conjunction

Boo

Or

Logical disjunction

Boo

Factory functions

Although they look a bit like functions, they are essentially classes. When you call them, you actually generate an instance of the type.

Int (), long (), float (), complex (), str (), Unicode (), basestring (), list (), tuple (), type ()

Dict (), BOOL (), set (), Frozenset (), Object (), Classmethod (), Staticmethod (), super (), property (), file ()

The first knowledge of Python (2) __python object

Related Article

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.