Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to understand that everything in python is an object

Shulou Source: shulou.com Published: 2022-06-01 19:44:21 10月03日 Update

This article mainly explains "how to understand everything in python". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to understand everything in python.

The computer is binary, and all data inside the computer is ultimately a binary representation. So how do we present numbers, words, images, sounds, actions, and so on when we use computers? There are many specific presentation methods and steps, which are determined by many factors, such as computer hardware, operating system, software and so on. We can only talk about some abstract concepts here.

Numbers, text, images, sounds, codes, actions, and so on are defined as data.

The data are varied and must be distinguished. The identity used to distinguish data is defined as a label.

The function of the computer is to process the input original data and then output the data. The steps of processing are defined as methods.

Now back to python, everything is an object, so what is an object? My understanding is that objects are the general name of data, labels, and methods.

Here's an example:

A = 65 # defines a variable a, assigned to 65 python sets the label of 65 to int by default, and int is the label of data print (a) type (a) b = chr (a) # defines a variable b, which is processed into strtype "A" by chr () method, and str is the label of data. Chr () is the method. Print (bpencil type (b)) out:65 A

Now I believe we all understand what the object is.

In python, the number number (including int, float, bool, complex), string string, tuple tuple, list list, dictionary dict, collection set, methods, classes, instances, and so on are all composed of data, labels, methods, etc., so everything is an object.

In fact, everything is not completely accurate in python. In python code, symbols such as () [] {} are not objects, they are meaningless, they just help to distinguish between code and data.

But the +, -, *,\, and so on operators are all objects, and they are actually special methods that can be customized by operator overloading.

At this point, I believe you have a deeper understanding of "how to understand everything in python". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Object data method label computer code variable number process binary content action image sound variety actual text is composed of step operator Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS MySQL Redmi OPPO Reno