Python source code compilation skills

Source: Internet
Author: User

The following articles mainly introduce the compilation of Python source code and some common skills. These contents are found on some portal websites and technical forums. I have not picked out many errors in the middle, thank you for your attention. I hope you can learn more.

PC began to appear. PCS were equipped with various software packages for processing files, including workbooks and word processing files. Graph Editor file. ABC users want to use ABC to write a small program, read some data from their word processing files, and then write the data to the spreadsheet, or vice versa. However, they sigh with hope that they can only blame IO for its incompetence.

Bill Venners: They want to process files, Guido van rosum: They want to process data, but the data stays in the file. ABC does not have the file concept, which complicate things. Extensibility Guido van rosum in Python: adding to the lack of file support in ABC is that it is not easy to extend the ABC language. If you think like this: "This language is implemented in C.

So we can add a function to its standard library to read files. Isn't that enough ?", That's a big mistake. ABC does not have a standard function library. It has built-in commands. However, parser. ABC also has built-in functions, but these functions are tied together with the runtime. It is difficult to add to the Standard Functions of the language.

For Python source code, I realized that scalability is an obvious top priority. I have learned that Python needs to be run on multiple platforms. that is, I know that we require Python to run on Amoeba we are developing and on UNIX. The latter is our desktop operating system. At the same time, I also thought that we would also need it to support Windows and Macintosh. I thought that some of these systems have common features.

For example, the standard I/O library, but some functions are not interconnected. if you want to draw something on a Windows screen, the code you write must be different from that on Macintosh and Unix, and the programming mode will be quite different. later, I conceived a flexible and scalable model for Python. I proposed: "We will provide a series of built-in object types for this language.

For example, dictionary, list, various numeric types, and strings. third-party programmers can easily add their own object types to the system. because ABC is designed as a relatively small language, it does not support namespace ). it only contains functions and procedures. you cannot group functions and processes.

Later, although they joined a namespace mechanism, I thought the mechanism was too crude. at that time, I had some experience with Modula-2 and Modula-3, so I decided to use the module as one of the main programming units of Python. I decided to let Python have two different modules: You can write modules in Python, but you can also write modules in Python in C. in addition, modules written in C can implement new data types.

Provides new objects. this idea was proven to be insightful because my colleagues, users, and myself at CWI began to write our own extension modules. these extension modules allow you to do what you want: Call the graphics library, data stream library, and operate on various data formats.

Bill Venners: So if I write a module in C, I can use it in my Python program, and the data type in the module is like that in Python? Guido van rosum: That's right. in the Python source code, only the import statement can be used in the module method. python import is a little different from Java import, but the ideas behind them are common.

Once you import a module name, the system will try to find this module in several different ways. we will set a search path to search for different types of files. if you are looking for a file for import foo, it will finally find a file named foo. py or foo. so (foo on Windows. dll.

Foo. py is a Python source file. the Python source file will be parsed and interpreted and executed in the future. this process allows the function/process to be used by the program. foo. so or foo. dll is the compiled machine code. This dynamic link library is implemented in C or C ++, but some people write their own extensions using Fortran. These extensions will be linked to some large Fortran libraries in the future.

From the Python perspective, there is no difference between the method of using the pre-compiled machine code module and that of using the Python source code module. they are all imported. you can list the content of the module to see what is in it. or, if you are familiar with the module, you can use it directly.

Guido van rosum: That's right. in Python, only the import statement can be used to use modules. python import is a little different from Java import, but the ideas behind them are common. Once you import a module name, the system will try to find this module in several different ways. We will set a search path to search for different types of files in it.

If you are looking for a file for import foo, it will finally find a file named foo. py or foo. so (foo. dll on Windows. Foo. py is a Python source file. the Python source file will be parsed and interpreted and executed in the future. this process allows the function/process to be used by the program. foo. so or foo. dll is the compiled machine code.

This dynamic link library is implemented in C or C ++, but some people write their own extensions using Fortran. These extensions will be linked to some large Fortran libraries in the future. From the Python perspective, there is no difference between the method of using the pre-compiled machine code module and that of using the Python source code module. You can list the module content to see what is in it. Or, if you are familiar with the module, you can use it directly.

  1. Introduction to Python system files
  2. How to correctly use Python Functions
  3. Detailed introduction and analysis of Python build tools
  4. Advantages of Python in PythonAndroid
  5. How to Use the Python module to parse the configuration file?

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.