How to define Python Functions

Source: Internet
Author: User

If you first define the concept of ing, you can simply define the function as, and the ing between non-empty number sets is called the Python function. Say_id is the function of an object. You can call it. Each object's function requires a self parameter, indicating the object [color.

In addition, the object can put together Python functions for data and operation data, which can be clear. Although there is a so-called data hiding concept, in Python, it is actually a convention that does not directly call data in objects. A function is used as a transit function. In fact, it is normal to understand the object orientation. In fact, sometimes it is necessary to use the intermediate sentiment. When can I use function programming.

Maybe you already feel what object-oriented programming is. In addition, some so-called OO rules do not require syntax support. If you have this idea in mind, what do you think? Can write OO code, no matter what language or syntax you use.

The mysteries of the graphic interface are actually not profound. I believe that many people start learning windows programming by writing a window and trying to understand the message and event-driven model. The general process is like this. The window is painted in pixels. You can think of a window as a window or a set of pixels. It's just like some people say that female looks just like flesh.

In addition, the buttons in the window, the editing of mines and various icons, No matter what looks like an "object", are essentially drivers with applications, libraries, or operating systems that call video cards, use the graphics card function to draw some points on the screen. The so-called "object" has many naming rules, and is generally a control in windows ).

The graphical interface is generally controlled by the mouse and keyboard. The mouse has its own image on the screen, that is, an arrow, of course, you can also adjust this image as another fun thing, it is your freedom ). The keyboard is generally represented as a dotted box, indicating the place where the keyboard's "Focus" is located.

Or the flashing vertical bar in the editing box. Python functions have one thing in common, that is, they all have a location to determine the object to be operated. When you click the mouse, you are operating on the space pointed to by the tip of the mouse arrow, and the keyboard press is also directed to the control where the focus is located.

What happened? The process is received by the operating system from the hardware level to the software level. The operating system can know where you click the mouse or keyboard, and whether you press the Left or Right button. The operating system also knows where the current window is located.

Based on various information, the operating system can know the window to which the "event" is sent as a "message. We should be able to understand what an event is, and a message is a struct in C. Several fields contain information about this event.

Then, like a letter, it is shipped from the operating system to the application where the window is located. Then the application has a pre-registered "Window Process", which is actually a function used to receive this "letter ". It is actually receiving the passed parameters.

Then, make some judgments and respond accordingly. This is the so-called event-driven. Without lengthy Code and all the details, if you really knew nothing about the process before, you would feel very confused. In fact, this story only gives you a perceptual knowledge. In fact, there is no need to worry about many things when using Windows in Python.

Basically, you only need to give some location parameters to the windows and controls you want, and set the parameters of some text prompts to display the window. Then, the Code tells the Python function to execute this function when the button is pressed, and then the window can respond.

Finally, remember to give a window exit method and everything will be OK. The complexity of saving is basically hidden by the database. The cost is a little slow, but I don't believe you can feel it unless your computer doesn't even see vcd smoothly. Therefore, you can safely enjoy this convenience.

  1. How to embed Python into C ++ applications?
  2. In-depth discussion of Ruby and Python syntax comparison
  3. Introduction to Python
  4. Python Learning Experience: version, IDE selection and coding Solutions
  5. Analysis of Python GIL and thread security

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.