11 Essential Python Knowledge Points for Beginners

Python is hailed as one of the most efficient programming languages in the world, often referred to as a “glue language.” Why is it so popular? Let’s discuss the 11 essential knowledge points for learning Python, which explain its widespread appeal.

Introduction to Python:Python is a high-level scripting language that combines interpretive, compiled, interactive, and object-oriented features.Python is designed with strong readability in mind, often using English keywords and unique syntax structures compared to other languages.Python is an interpreted language: this means that there is no compilation step during development, similar to PHP and Perl.Python is an interactive language: this means you can directly interact and execute your programs at a Python prompt.Python is an object-oriented language: this means Python supports object-oriented programming techniques, encapsulating code within objects.Python is a language for beginners: it is a great language for novice programmers, supporting a wide range of application development, from simple text processing to web browsers and games.History of Python

Python was designed by Guido van Rossum at the National Research Institute for Mathematics and Computer Science in the Netherlands in the late 1980s and early 1990s.

Python itself has evolved from several other languages, including ABC, Modula-3, C, C++, Algol-68, SmallTalk, Unix shell, and other scripting languages.

Like Perl, Python source code is also governed by the GPL (GNU General Public License).

Today, Python is maintained by a core development team, with Guido van Rossum playing a crucial role in guiding its progress.

Features of Python1. Easy to learn: Python has relatively few keywords, a simple structure, and a well-defined syntax, making it easier to learn.2. Easy to read: Python code is more clearly defined.3. Easy to maintain: The success of Python lies in the fact that its source code is relatively easy to maintain.4. A comprehensive standard library: One of Python’s greatest advantages is its rich library, which is cross-platform and compatible with UNIX, Windows, and Macintosh.5. Interactive mode: The support for interactive mode allows you to enter code from the terminal and get results, making it ideal for testing and debugging code snippets.6. Portable: Due to its open-source nature, Python has been ported (made to work) on many platforms.7. Extensible: If you need a piece of critical code to run quickly, or if you want to write an algorithm that you do not wish to open-source, you can use C or C++ to complete that part of the program and then call it from your Python program.8. Database: Python provides interfaces to all major commercial databases.9. GUI programming: Python supports GUI creation and can be ported to many system calls.10. Embeddable: You can embed Python into C/C++ programs, allowing your program’s users to gain “scripting” capabilities.1. What application scenarios is Python suitable for?

There is no fixed answer. Many people say Python is not suitable for developing GUI applications, but Python’s own IDE—IDLE and third-party IDE—Eric are written in Python.

Currently, many people use it for web development, utilizing frameworks like Django and web.py, and if I’m not mistaken, Flask as well.

Another common use is employing Python as glue, integrating with various languages to achieve certain software functionalities. You might notice Python’s presence when installing some software.

I have personally used Python to simulate port forwarding and DNS services, so it really depends on the use case rather than how it can be used.

Additionally, Python is quite suitable for big data analysis, from loading to analyzing and saving results, Python has a complete set of modules to handle it.

2. Can Python handle big data?

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

Python’s characteristics are more about efficient development and simple maintenance; let C handle the speed. Many issues actually arise from the coder’s lack of better usage rather than insufficient efficiency. For example, sorting: Python has very efficient built-in C-compiled modules, yet some still choose to write their own algorithms, which makes it strange if the result is not slow.

Moreover, whether the requirement is CPU-intensive or IO-intensive should be considered. If it is CPU-intensive, it is advisable to implement that part in C; IO-intensive efficiency will not change much because of Python.

C is efficient, but building frameworks can be cumbersome, so it’s best to combine the two, which is why Python is referred to as a glue language.

3. Can Python completely replace Shell?

Absolutely, Python can achieve all the functions of Shell, with less code, better structure, and improved readability. Additionally, Python can implement functions that Shell cannot, such as the Socket module for network communication used in operations, the Django framework for web, and the psutil module for performance collection. Shell is heavily dependent on OS commands, while Python can largely avoid that.

Having a Shell IDE is a significant issue. Although Python’s native IDE is not great, third-party IDEs are quite powerful. While they may not compare to Microsoft’s Visual Studio, they can fully meet Python’s development needs.

Regarding Python’s efficiency, it supports multiple processes, threads, and coroutines (which are smaller than threads), and its concurrency is superior to Shell. Most of Python’s core modules are implemented in C, thus increasing efficiency. If necessary, Python modules can be rewritten in C to enhance performance, or you can use C Python, a Python interpreter fully implemented in C.

4. Can Python access common databases?

Yes, Python can access various common databases, such as Oracle, MySQL, Vertica, SQLServer, etc., simply by loading the corresponding modules. The module list is as follows:

Oracle: cx_OracleMySQL: MySQLdb5. Is Python development procedural, functional, or object-oriented?

Although Python is an interpreted language, it has been designed as an object-oriented language from the beginning, where everything in Python is an object. Therefore, creating classes and objects in Python is very easy, and if you prefer procedural or functional styles, that is also acceptable; Python does not impose strict limitations.

**The object-oriented features of Python are as follows:Encapsulation

In object-oriented programming, the term object can essentially be seen as a collection of data (attributes) and a series of methods that can access and manipulate that data. The traditional notion of “program = data structure + algorithm” is encapsulated and simplified to “program = object + message.” An object is an instance of a class, and the abstraction of a class requires encapsulation. Encapsulation allows the caller to use the object directly without caring about how it is constructed.

InheritanceClass Inheritance:

Inheritance is directly perceived as a code reuse behavior. It can be understood that inheritance establishes specialized class objects based on ordinary classes, where subclasses and their parent classes have an IS-A relationship.

Multiple Inheritance:

Unlike C#, Python supports multiple class inheritance (C# can inherit from multiple interfaces but can inherit from only one class). The multiple inheritance mechanism can be very useful, but it can also complicate matters.

Polymorphism

Polymorphism means that the same operation can be applied to different objects, but they may present results in various forms. In Python, polymorphism is used whenever there is a need to perform actions on objects without knowing their exact types. Methods are polymorphic, and operators are also polymorphic.

6. How to quickly master Python?

Reading the official documentation can satisfy daily needs, and the official documentation has a Chinese translation, making it more convenient for learning. However, these cover only basic syntax and common modules; the important aspect of learning Python is mastering modules. Fast and efficient development relies on the application of modules, and standing on the shoulders of giants saves time and effort.

However, the most crucial part of learning Python is understanding modules rather than the syntax itself. The syntax of Python is very simple; anyone who has taken a university course in C or data structures, or even those who haven’t studied at all, can easily grasp it. Mastering the syntax allows one to achieve Shell functionalities, but to improve, learning modules is essential, such as:

psutil: for performance informationsocket: for basic network communicationIPy: for IP address-related processingdnsptyhon: for domain name-related processingdifflib: for file comparisonpexpect: for screen information retrieval, commonly used for automationparamiko: for SSH clientXlsxWriter: for Excel-related processing

There are many other functional modules, and new modules, frameworks, and components are being developed daily, such as PythonJS for bridging with Java, and Python can even be used to write Map and Reduce.

7. Does Python have dedicated IDE tools?

Yes, IDLE is a Python IDE tool implemented in Python, but honestly, its functionality is quite limited. My commonly used IDEs are as follows:

PyCharm

PyCharm is a Python IDE developed by JetBrains. It includes general IDE features like debugging, syntax highlighting, project management, code navigation, intelligent suggestions, auto-completion, unit testing, version control, etc. Additionally, PyCharm offers excellent features for Django development and supports Google App Engine. Even cooler, PyCharm supports IronPython!

Wing IDE

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

NotePad++

Simple and convenient, but only suitable for temporary changes.

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

8. What common methods are used to implement system automation monitoring with Python?

To be precise, it should refer to which modules are used. Health monitoring requires psutil to monitor performance, along with the communication Socket, for logging Paramiko, telnetlib for FTP, and ftplib.

The principle is essentially data collection—local data processing—data transmission. If done well, you can also present data or send it to open-source tools like Zabbix.

I also used an open-source monitoring tool that automatically blocks after exceeding a specified number of attempts.

9. On which platforms can Python run? How is its cross-platform capability?

It supports common mainstream platforms such as AIX, HPUX, Solaris, Linux, Windows, etc. Except for Windows, common Unix and Linux platforms generally come with native Python, although the version is usually lower. Regarding cross-platform capabilities, like other cross-platform languages, it’s important to note that some specific modules are unique to certain platforms, but overall cross-platform capability is quite good, and there’s no need to write multiple code sets to adapt to various platforms.

However, this does not mean there are no limitations: first, the intermediate files .py, .pyc, and .pyo of the same version are cross-platform; secondly, PC and mobile terminals, such as phones and tablets, cannot cross platforms (the reasons will be discussed in the next point); finally, it cannot cross processor architectures, such as Intel vs. ARM, or 64-bit vs. 32-bit.

10. How to use Python to improve development efficiency?

Because many low-level tasks do not need to be written from scratch in Python, and with rich module resources, proper use will certainly enhance development efficiency. Various frameworks also provide a foundation for rapid development.

11. How is Python’s running speed?

Generally, Java is faster than Python. Except for Python’s calls to C extensions (which can also directly use CPython).

In response to criticisms about Python’s speed, Python’s creator, Guido van Rossum, stated:

If you find performance bottlenecks in the system you are developing, the most efficient approach is to identify the problematic code block and replace that functionality or module with code written in a faster language like C or C++, rather than rewriting the entire system in C or C++, because for most code, the speed of the language is irrelevant.

END

Long press or scan the QR code below to get free Python public courses and hundreds of gigabytes of learning materials compiled by experts, including but not limited to Python e-books, tutorials, project orders, source code, and more.

▲ Scan the QR code - Get it for free
Disclaimer: If there is any infringement, please contact the editor for deletion.

Leave a Comment