Python learning notes -- Understanding Python

Source: Internet
Author: User

Python isCommunityDriven, open-source, unique, concise, readable, multi-purpose, dynamic scripting language.

 

Advantages:

Optimized development speed and guaranteedCodeTo makeProgramQuickly complete project development.

 

Disadvantages:

The execution speed is not fast enough (compared with C and C ++ ).

 

Python code is often stored in a file suffixed with. py and does not need to be compiled. The implementation mechanism is as follows:

Source code→ Bytecode → Python Virtual Machine

If the worker generates the. exe file (freezing the binary file), you can usually use some tools: py2exe (Windows)/pyinstaller (Linux/Unix ). The Mechanism is to embed python into a binary file to implement the python environment.

 

In the interactive interpreter, python can automatically print the expression result and redirect it to a file, as shown in

Python spam. py> saveit.txt

I have long been writing C/C ++ code and admire this function!

 

[Translation]

Python is an easy-to-learn and powerful language. It has an efficient data structure and simple and efficient object-oriented programming ideas. Python's elegant syntax, dynamic data types, and its literal nature make it not only an ideal scripting language, it also enables quick development on almost all platforms.

Python interpreters and their standard libraries are fully open-source and can be obtained and written through http://www.python.org. The website can also publish third-party Python modules, programs, tools, and documents.

Python interpreters can be easily combined with development in other languages. python can also be used as an extension tool in other languages.

 

 

Appendix:

Http://docs.python.org/tutorial

The Python tutorial

Release:

2.7

Date:

July 14,201 1

Python is an easy to learn, powerful programming language. it has efficient high-level data structures and a simple but valid tive approach to object-oriented programming. python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and Rapid Application Development in advance areas on most platforms.

The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python web site, http://www.python.org/, and may be freely distributed. the same site also contains distributions of and pointers to have free third party Python modules, programs and tools, and additional documentation.

The Python interpreter is easily extended with new functions and data types implemented in C or C ++ (or other extends ages callable from C). python is also suitable as an extension language for customizable applications.

This tutorial introduces the reader informally to the basic concepts and features of the Python language and system. it helps to have a python interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well.

For a description of standard objects and modules, seeThe Python standard library.The Python language referenceGives a more formal definition of the language. To write extensions in C or C ++, readExtending and embedding the python InterpreterAndPython/C api reference manual. There are also several books covering python in depth.

This tutorial does not attempt to be comprehensive and cover every single feature, or even every commonly used feature. instead, it introduces features of Python's most noteworthy features, and will give you a good idea of the language's flavor and style. after reading it, you will be able to read and write Python modules and programs, and you will be ready to learn more about the varous Python library modules described inThe Python standard library.

TheGlossaryIs also worth going through.

  • 1. whetting your appetite
  • 2. Using the python Interpreter
      • 2.1. Invoking the interpreter
        • 2.1.1. Argument passing
        • 2.1.2. Interactive Mode
      • 2.2. the interpreter and its environment
        • 2.2.1. Error Handling
        • 2.2.2. executable Python scripts
        • 2.2.3. source code encoding
        • 2.2.4. the interactive Startup File
  • 3. An informal introduction to Python
      • 3.1. Using python as a calculator
        • 3.1.1. Numbers
        • 3.1.2. Strings
        • 3.1.3. Unicode strings
        • 3.1.4. Lists
      • 3.2. first steps towards programming
  • 4. More control flow tools
      • 4.1.IfStatements
      • 4.2.ForStatements
      • 4.3.Range ()Function
      • 4.4.BreakAndContinueStatements, andElseClses on Loops
      • 4.5.PassStatements
      • 4.6. Defining Functions
      • 4.7. More on defining functions
        • 4.7.1. Default argument values
        • 4.7.2. Keyword arguments
        • 4.7.3. Arbitrary argument lists
        • 4.7.4. unpacking argument lists
        • 4.7.5. Lambda forms
        • 4.7.6. documentation strings
      • 4.8. intermezzo: coding style
  • 5. Data Structures
      • 5.1. More on lists
        • 5.1.1. Using lists as stacks
        • 5.1.2. Using lists as queues
        • 5.1.3. Functional programming tools
        • 5.1.4. List comprehensions
        • 5.1.5. nested list comprehensions
      • 5.2.DelStatement
      • 5.3. tuples and Sequences
      • 5.4. Sets
      • 5.5. Dictionaries
      • 5.6. looping Techniques
      • 5.7. More on conditions
      • 5.8. Comparing SEQUENCES AND OTHER TYPES
  • 6. Modules
      • 6.1. More on modules
        • 6.1.1. Executing modules as scripts
        • 6.1.2. The module search path
        • 6.1.3. "compiled" Python files
      • 6.2. standard modules
      • 6.3.Dir ()Function
      • 6.4. Packages
        • 6.4.1. Importing * from a package
        • 6.4.2. Intra-package references
        • 6.4.3. packages in multiple directories
  • 7. Input and Output
      • 7.1. fancier output formatting
        • 7.1.1. Old string formatting
      • 7.2. Reading and Writing files
        • 7.2.1. Methods of file objects
        • 7.2.2.PickleModule
  • 8. Errors and exceptions
      • 8.1. syntax errors
      • 8.2. Exceptions
      • 8.3. Handling exceptions
      • 8.4. Raising exceptions
      • 8.5. User-defined conditions
      • 8.6. Defining clean-up actions
      • 8.7. predefined clean-up actions
  • 9. Classes
      • 9.1. A word about names and objects
      • 9.2. Python scopes and namespaces
      • 9.3. A first look at classes
        • 9.3.1. Class Definition syntax
        • 9.3.2. class objects
        • 9.3.3. instance objects
        • 9.3.4. method objects
      • 9.4. random remarks
      • 9.5. Inheritance
        • 9.5.1. Multiple inheritance
      • 9.6. Private Variables
      • 9.7. odds and ends
      • 9.8. Exceptions are classes too
      • 9.9. iterators
      • 9.10. Generators
      • 9.11. Generator expressions
  • 10. brief tour of the standard library
      • 10.1. Operating System Interface
      • 10.2. File wildcards
      • 10.3. command line arguments
      • 10.4. Error output redirection and program termination
      • 10.5. String Pattern Matching
      • 10.6. Mathematics
      • 10.7. Internet access
      • 10.8. dates and times
      • 10.9. Data Compression
      • 10.10. Performance Measurement
      • 10.11. Quality Control
      • 10.12. Batteries authorized DED
  • 11. brief tour of the standard library-Part II
      • 11.1. Output formatting
      • 11.2. Templating
      • 11.3. Working with binary data record layouts
      • 11.4. multi-threading
      • 11.5. Logging
      • 11.6. Weak references
      • 11.7. Tools for working with lists
      • 11.8. Decimal Floating Point Arithmetic
  • 12. What now?
  • 13. Interactive input editing and history substitution
      • 13.1. line editing
      • 13.2. History substitution
      • 13.3. key bindings
      • 13.4. Alternatives to the interactive Interpreter
  • 14. Floating Point Arithmetic: Issues and limitations
      • 14.1. Representation Error

 

 

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.