A Comprehensive Guide to Python: Understanding Its Pros and Cons

In recent years, Python has been praised to the heavens. Many students are unclear about what Python can actually do and blindly start learning it. Today, I will provide a brief overview of Python’s application areas to help those who want to learn Python find the right direction and avoid confusion.

2. Characteristics of Python

Here, I will share my perspective. Firstly, Python is a cross-platform language with a very concise syntax, allowing shorter code to accomplish more tasks. Additionally, it is a scripting language, enabling you to write scripts anytime and anywhere to process data, which is extremely convenient. It’s also an object-oriented language, making it very friendly to beginners. Python has a rich set of libraries for various fields, such as web scraping, machine learning, data processing, image processing, etc., meeting the needs of most areas. More importantly, Python is a “glue language,” easily calling mainstream C, C++, and Java libraries. But is this the reason why Python has been “praised”? Of course not! If a language has no practical application, it doesn’t matter how excellent it is; it cannot be considered excellent.

3. Application Areas of Python

Next, let’s take a look at the practical applications of Python in various fields.

3.1 Web Scraping

Today, internet data has become the most core asset for any company. However, the volume of information on the internet is enormous. In the future, quickly obtaining useful public information will require web scraping. Python is particularly adept at writing scrapers. By using the requests library to fetch web data and BeautifulSoup to parse and organize the data, you can quickly and accurately obtain the information. I used web scraping to gather paid music, articles, videos, images, etc., which helped me get through a lot of boring times during the pandemic. (Of course, if you don’t do it well, you might get a call: “Hello, are you Mr./Ms. …? We have a record showing you are suspected of a crime. We are downstairs, please come with us…”)

3.2 Web Development

Web development isn’t limited to Java; Python can also facilitate rapid web development. Frameworks like Django and Flask are well-known Python web frameworks that fully utilize Python’s features for efficient web development.

A Comprehensive Guide to Python: Understanding Its Pros and Cons

3.3 Software Testing

Python scripts for testing help testers lose fewer hairs. Currently, most mainstream automated testing frameworks support Python scripts. Moreover, many job postings for testers require knowledge of Python as a necessary skill.

3.4 Operations and Maintenance

For the operation and maintenance management of large platforms, even automated operations, Python has powerful tools such as fabric, saltstack, and ansible. Additionally, for cloud computing and network operations, you can find resources to learn from.

3.5 Artificial Intelligence

The core of artificial intelligence lies in algorithms and models. It requires a quick focus on the problem itself and the ability to interactively train models. Python is the only language that can meet these needs. Currently, the two major deep learning frameworks, TensorFlow and Pytorch, are both written in Python, and the compact and elegant Darknet is also developed in Python. I am currently using Python for deep learning-related development. Using Java for this would be very complex because neural network computations involve a lot of complex multiplication operations on high-dimensional matrices.

Python’s syntactical features can handle these high-dimensional data computations well. We can then train weight models to recognize the number and location of targets in images.

3.6 Data Analysis and Mining

Handling massive amounts of data is Python’s strong suit. Therefore, Python is also a necessary skill for data engineers. Data cleaning is very convenient. The data analysis library Pandas provides an easy-to-use API for analyzing, structuring, and graphically displaying data. Python also offers quick visualization tools such as matplotlib and holoviews for rapid data visualization.

4. Not Just Programmers Use Python

Python is not only suitable for developers; many professionals in the finance sector also use Python for quantitative finance. Office workers who know Python can easily perform batch operations on Excel, Word, and PDF, making them true masters of time management. Unfortunately, Python still cannot be used for cooking.

5. Python is Easy to Get Started With

In fact, for those with a programming background, it is possible to master the basic syntax of Python in as little as half a day. I personally recommend Python as the second language for developers. However, to use Python proficiently, systematic learning is still necessary. Some commonly used libraries, like Numpy and Pandas, are often more challenging to learn than Python itself, requiring systematic study and practice.

Summary of Python Learning Path

A compilation of technical points across all directions of Python, forming a knowledge point summary for various fields. Its purpose is to help you find corresponding learning resources based on the above knowledge points, ensuring a more comprehensive learning experience.

6. Advantages of Python

1) Simple Syntax

Compared to traditional languages like C/C++ and Java, Python has less strict requirements for code formatting. This leniency allows users to write code more comfortably without spending too much effort on trivial details. Here are two typical examples:

Python does not require a semicolon at the end of every statement, although writing one is not incorrect;

When defining a variable, there is no need to specify its type, and the same variable can hold different types of data.

These two points are also common characteristics of many scripting languages.

Python is a programming language that represents minimalism. Reading well-formatted Python code feels like reading an English paragraph, making it very close to human language. Hence, people often say that Python is a programming language with pseudocode characteristics.

Pseudocode is a language for describing algorithms that lies between natural language and programming languages. The purpose of writing pseudocode is to make the described algorithm easier to implement in any programming language, such as C, C++, Java, etc. Therefore, pseudocode must be clearly structured, simple, and readable, resembling natural language. If you have studied data structures and read the works of Yan Weimin, you know what pseudocode is.

Why is simplicity considered a killer feature? Once something is simple, it becomes pure; when developing Python programs, we can focus on solving the problem itself without worrying about the minutiae of syntax. Doing something pure in a simple environment is a true pleasure.

2) Python is Open Source

Open source means that all users can see the source code.

Python’s open source nature manifests in two aspects:

① The code written by programmers using Python is open source.

For example, if we develop a BBS system (i.e., an online forum) and make it available for download on the internet, users downloading it will receive all the source code and can modify it freely. This is also a characteristic of interpreted languages, as running a program requires the source code.

② The Python interpreter and modules are open source.

The official release of the Python interpreter and module code as open source is intended for all Python users to participate in improving Python’s performance and fixing vulnerabilities. The more the code is studied, the more robust it becomes.

There will always be a small group of people who either do not seek fame and fortune or aim to achieve certain goals by continuously strengthening and improving Python. Do not assume that everyone is only interested in immediate benefits; some elites will fish long lines for big catches, and some geeks will do amazing things.

3) Python is Free

Open source does not mean free; open source software and free software are two different concepts. However, most open source software is also free software. Python is one such language; it is both open source and free.

Users can develop or publish their programs using Python without paying any fees or worrying about copyright issues, even for commercial purposes.

4) Python is a High-Level Language

High-level here refers to Python’s deep encapsulation, which hides many low-level details. For example, Python automatically manages memory (allocating when needed and releasing when not needed).

The advantage of high-level languages is ease of use without worrying about trivial details; the downside is that it can lead to superficial understanding, knowing how it works without understanding why.

5) Python is an Interpreted Language and Cross-Platform

5) Python is an Object-Oriented Programming Language

Object-oriented programming is a characteristic of most “modern” languages (i.e., third-generation programming languages), otherwise, it would be challenging to develop medium to large programs.

Although Python supports object-oriented programming, it does not force you to use this feature. Java is a typical object-oriented programming language that mandates organizing code in classes and objects. Besides Python and Java, C++, C#, PHP, Ruby, and Perl also support object-oriented features.

In addition to object-oriented programming languages, there are procedural programming languages, with C being the most typical representative.

6) Python is Powerful (Many Modules)

Python has numerous modules that cover almost all common functionalities, from simple string processing to complex 3D graphics rendering, all easily accomplished with Python modules.

The Python community is well-developed. In addition to the core modules provided by the official Python, many third-party organizations, including Google, Facebook, and Microsoft, also participate in module development.

In Python, even for some niche functionalities, there are often corresponding open-source modules, sometimes more than one.

7) Python is Highly Extensible

Python’s extensibility is reflected in its modules. Python has the richest and most powerful libraries or modules among scripting languages, covering file operations, GUI programming, network programming, database access, and most application scenarios.

It is noteworthy that the underlying code of these libraries is not necessarily all Python; many C/C++ codes are also present.

For example, when a critical piece of code needs to run faster, you can implement it in C/C++ and then call it from Python. Python can “glue” other languages together, which is why it is called a “glue language.”

Python compensates for its slow execution efficiency to some extent due to its good extensibility.

7. Disadvantages of Python

Despite the various advantages mentioned above, Python also has its drawbacks.

1) Slow Execution Speed

Slow execution speed is a common issue for interpreted languages, and Python is no exception.

Python’s slow speed is not only due to the “translating” of source code while running but also because Python is a high-level language that hides many low-level details. This comes at a significant cost; Python has to do a lot of work, some of which is resource-intensive, such as memory management.

Python’s execution speed is among the slowest, far slower than C/C++ and even slower than Java.

However, the drawback of slow speed often does not pose significant problems. First, computer hardware is becoming faster; spending more money can yield high-performance hardware, and improvements in hardware performance can compensate for software performance shortcomings.

Second, some application scenarios can tolerate slow speeds. For example, for websites, most of the time users spend opening a webpage is waiting for network requests, not waiting for the server to execute webpage programs. Whether the server takes 1ms or 20ms to execute a program is imperceptible to users, as network connection times can often reach 500ms or even 2000ms.

2) Difficult to Encrypt Code

Unlike compiled languages, where the source code is compiled into executable programs (this compilation process is akin to encrypting the source code), Python runs the source code directly, making it relatively difficult to encrypt.

END

Python public courses and a compilation of hundreds of gigabytes of learning materials organized by experts. We won't display the materials here; you can scan the QR code below and reply with 'python' to receive them.
Disclaimer: If there is any infringement, please contact the editor for deletion. Long press the QR code above for 2 seconds and reply with 'python' to obtain the materials.

Leave a Comment