Home > Backend Development > Python Tutorial > 11 knowledge points you must know to get started with Python_python

11 knowledge points you must know to get started with Python_python

不言
Release: 2018-04-04 16:39:41
Original
1870 people have browsed it

This article mainly introduces 11 knowledge points that you must know to get started with Python to help you better understand python. Interested friends can refer to it

Python is known as the world's most famous knowledge point An efficient programming language, also known as the "glue language", why is it so popular? Let's talk about the 11 essential knowledge points for getting started with Python, which is why it is so popular. Reason.

Introduction to Python

Python is a high-level scripting language that combines interpreted, compiled, interactive and object-oriented scripting.

Python is designed to be highly readable. Compared with other languages, it often uses English keywords and some punctuation marks in other languages. It has a more distinctive grammatical structure than other languages.

Python is an interpreted language: This means that there is no compilation link in the development process. Similar to PHP and Perl languages.

Python is an interactive language: this means that you can write the program you write in a Python prompt and execute it interactively directly.

Python is an object-oriented language: This means that Python supports object-oriented style or programming techniques in which code is encapsulated in objects.

Python is a Beginner's Language: Python is a great language for beginning programmers, supporting a wide range of application development, from simple word processing to WWW browsers to games.

Python development history

Python was developed by Guido van Rossum in the late 1980s and early 1990s at the National Institute of Mathematics and Computer Science in the Netherlands. Designed.
Python itself has been developed from many other languages, including ABC, Modula-3, C, C++, Algol-68, SmallTalk, Unix shell and other scripting languages, etc.
Like the Perl language, Python source code also follows the GPL (GNU General Public License) agreement.
Now Python is maintained by a core development team, with Guido van Rossum still occupying a crucial role in guiding its progress.

Python Features

1. Easy to learn: Python has relatively few keywords, a simple structure, and a clearly defined syntax, making it easier to learn. Simple.

2. Easy to read: Python code is more clearly defined.

3. Easy to maintain: The success of Python is that its source code is quite easy to maintain.

4. An extensive standard library: One of Python’s biggest advantages is its rich library, which is cross-platform and compatible with UNIX, Windows and Macintosh.

5. Interactive mode: Interactive mode support, you can enter the language to execute the code and get the results from the terminal, interactive testing and debugging code snippets.

6. Portable: Based on its open source nature, Python has been ported (that is, made to work) to many platforms.

7. Extensible: If you need a critical piece of code that runs very fast, or want to write some algorithms that you don’t want to open up, you can use C or C++ to complete that part of the program, and then start it from your Python called in the program.

8. Database: Python provides interfaces to all major commercial databases.

9.GUI programming: Python supports GUIs that can be created and ported to many system calls.

10. Embeddable: You can embed Python into a C/C++ program, allowing users of your program to gain "scriptability" capabilities.

1. What application scenarios is Python suitable for?

There is no fixed answer to this. Many people say that Python is not suitable for developing GUI programs, but Python's own IDE - IDEL and third-party IDE - Eric are written in Python.

Currently, I see more people writing for the Web, using frameworks such as Django, web.py, and yes, Flask too.
There is also a situation where it is used more often. Python is used as glue, combined with various languages, to jointly complete certain software functions. Pay attention and you may find that Python is used when installing some software.

I personally have used Python to simulate port forwarding and DNS services, etc., so it really depends on how it works, not how it can be used.

In addition, Python is also more suitable for big data analysis. From loading to analysis to saving results, Python has a complete set of modules to deal with it.

2. Is Python capable of handling big data?

Python is very suitable for big data-related analysis. The built-in C-compiled module can handle common operations. For some extreme algorithms, it is recommended to rewrite the relevant modules in C.

The characteristics of Python itself are more efficient development and simple maintenance. Leave the speed to C. More problems actually come from the people who write the code not using it better, rather than insufficient efficiency. high. For example, for sorting, Python originally has a very efficient built-in C-compiled module, but it has to write the algorithm by itself. It is strange that the result is not slow.

It also depends on whether the requirement is CPU-intensive or IO-intensive. If it is CPU-intensive, it is recommended that this part of the operation be implemented in C. The efficiency of IO-intensive operations will not change much because of Python.

The efficiency of C is high, but it is also difficult to build the framework, so it is better to combine it. For this reason, Python is called the glue language.

3. Can Python completely replace Shell?

Absolutely, Python can implement all the functions of Shell, with less code, better structure, and better readability. However, the functions that Python can implement may not be implemented by Shell, such as those used in operation and maintenance. The Socket module for network communication, the Django framework for WEB, the psutil module for performance collection, etc., and Shell has a strong dependence on operating system commands, which Python can avoid to a greater extent.

Using a Shell IDE is a big problem. Although Python’s native IDE is not very good, third-party IDEs are still very powerful. Although they cannot be compared with Microsoft’s Virtual Studio, they can still Fully meets Python development needs.

Let’s talk about the efficiency of Python. Python supports multi-process, multi-thread and coroutine (one level smaller than thread), and the program concurrency is higher than that of Shell. Python's core modules are basically implemented in C, so they are more efficient. If necessary, the Python modules that need to be implemented in Python may be rewritten in C to improve efficiency. Of course, you can also directly use C Python, a Python interpreter that is directly implemented entirely in C.

4. Can Python access common databases?

Yes, Python can access various common databases, such as Oracle, MySQL, Vertica, SQLServer, etc. Just load the corresponding module. The module list is as follows:
Oracle: cx_Oracle
MySQL: MySQLdb

#5. Is Python development oriented towards procedures, functions or objects?

Although Python is an interpreted language, it has been an object-oriented language from the beginning of its design. For Python, everything is an object. Because of this, it is very easy to create a class and object in Python. Of course, if you are used to process-oriented or function-oriented writing, it is also possible. Python does not impose hard restrictions.

The object-oriented features of Python are as follows:

Encapsulation

The term object in object-oriented programming ( Object) can basically be regarded as a collection of data (properties) and a series of methods that can access and operate these data. In the traditional sense, "program = data structure + algorithm" is encapsulated, "covered up" and simplified to "program = object + message". Objects are instances of classes, and the abstraction of classes needs to be encapsulated. Encapsulation allows the caller to use the object directly without caring about how the object is constructed.

Inheritance

Class inheritance:

The direct feeling of inheritance is that it is a behavior of reusing code . Inheritance can be understood as establishing a special class object based on an ordinary class. The subclass has an IS-A relationship with the parent class it inherits.

Multiple inheritance:

Unlike C#, Python supports multiple class inheritance (C# can inherit from multiple Interfaces, but at most one class). The multiple inheritance mechanism is sometimes useful, but it can easily complicate things.

Polymorphism

Polymorphism means that the same operation can be used on different objects, but they may appear in multiple forms result. In Python, polymorphism is used whenever you don't know what type an object is, but you need the object to do something. Methods are polymorphic and so are operators.

6. How to master Python quickly?

Reading the official documents can meet your daily needs. The official documents are translated into Chinese, making it easier to learn. But these are basic syntax and common modules. The most important thing for learning Python is modules. Fast and efficient development relies on the application of modules. Standing on the shoulders of predecessors will save a lot of time and effort.

But the most important thing about learning Python is learning modules, not the grammar itself. Python’s grammar is very simple. As long as you have studied C or data structure courses in college, even people who have never learned it can easily master it. . Mastering the syntax can already realize the functions of Shell, but it is essential to improve the learning of modules. For example, operation and maintenance personnel often use:

psutil: Obtain performance information

socket: basic network communication

IPy: IP address related processing

dnsptyhon: domain name related processing

difflib: file comparison

pexpect: screen information acquisition, Commonly used for automation

paramiko: SSH client

XlsxWriter: Excel related processing

There are many other functional modules, and there are new modules, frameworks, Components are generated, such as PythonJS for bridging with Java, and even Python can write Map and Reduce.

7. Does Python have a dedicated IDE tool?

Yes, IDEL is a Python IDE tool implemented in Python, but to be honest, its functionality is not very good. The IDE I commonly use personally is as follows:

PyCharm

PyCharm is a Python IDE developed by JetBrains. PyCharm is used for the functions that general IDEs have, such as debugging, syntax highlighting, project management, code jumps, smart prompts, auto-completion, unit testing, version control... In addition, PyCharm also provides some good functions for Django development also supports Google App Engine. What’s even cooler is that PyCharm supports IronPython!

Wing IDE

Wingware's Python IDE is compatible with Python 2.x and 3.x, and can be combined with Django, matplotlib, Zope, Plone, App Engine, PyQt, PySide, wxPython, PyGTK, Tkinter, mod_wsgi, pygame, Maya, MotionBuilder, NUKE, Used by Blender and other Python frameworks. Wing supports test-driven development and integrates unit testing, nose and Django framework execution and debugging functions. Wing IDE starts and runs very quickly and supports Windows, Linux, OS X and Python versions.

NotePad++

Simple and convenient, but only suitable for temporary changes.

Others include: Eclipse withPyDev, Sublime Text, Komodo Edit, Pyer, The Eric Python IDE, Interactive Editor for Python

8. Use Python to realize system automation What are the common methods of monitoring?

To be precise, what modules should there be? For health monitoring, psutil must be used to monitor performance. Sockets for communication, Paramiko, telnetlib for login, and ftplib for ftp will also be used.

The basic principle is to collect data - process data locally - transmit data. If it is more complete, you can make a presentation of the data, or you can send the data to open source tools such as Zabbix.

I also use an open source monitoring network for spying. If it exceeds the specified number of times, it will be automatically blocked.

9. What platforms can Python run on? How is it cross-platform?

Supports common mainstream platforms, such as AIX, HPUX, Solaris, Linux, Windows, etc. Common Unix and Linux platforms except Windows all have native Python, but the version is generally lower. Regarding cross-platform, just like other cross-platform languages, it should be noted that some individual modules are unique to a single platform, but the overall cross-platform performance is still very good. There is no need to write multiple sets of code to adapt to multiple platforms.

But this does not mean that there are no restrictions at all: first, the intermediate files .py, .pyc and .pyo of the same version are cross-platform; secondly, PC and mobile terminals, such as mobile phones and Pads cannot be cross-platform. Platform (see the next item for the reason); finally, it cannot cross processor architectures, such as Intel and ARM, 64-bit and 32-bit.

10. How to use Python to improve development efficiency?

Because you don’t need to write many low-level things in Python yourself, and the module resources are rich. If used properly, development efficiency will of course be improved, and various frameworks also provide the basis for rapid development.

11. How fast is Python running?

Usually Java is faster than Python. Except for calling C extensions in Python (you can also use CPython directly).
Regarding the criticism that Python is too slow, Python language author Guido van Rossum said:

If the system you develop finds a performance bottleneck, usually the most efficient way is to find the problematic code block and use Write some code in a faster language like C or C++ to replace that function or that module instead of rewriting the entire system in C or C++ because for most of the code the speed of the language is irrelevant.

Learning is a person’s greatest accomplishment. Through learning, you can not only improve your realm, but also enrich your knowledge and lay the foundation for future employment. Learning Python is a good opportunity to develop yourself. After all, in the era of artificial intelligence It has arrived, and Python is very promising as the main force in the artificial intelligence era. The dream has not decayed, and there is still sweat along the way. come on!

Recommended book list:

Every Python expert in your eyes should have this book list

The Python book list will not be limited

Ten good Python books that cannot be missed

Related recommendations:

A good introductory tutorial on Python_python

Detailed Python introductory tutorial to learn Python_python in 1 hour

Sharing the process of getting started with Python

The above is the detailed content of 11 knowledge points you must know to get started with Python_python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template