01 How to Step by Step Become a Python Expert

01 How to Step By Step Become a Python Expert #

Hello, I’m Jingxiao.

In my work, I often hear programmers complain that there are too many computer programming languages nowadays and it’s hard to keep up. Some people have been using Java for many years, but when faced with a project that suddenly requires Python, they feel lost and under immense pressure.

As we all know, the main language used at Facebook is Hack (an evolved version of PHP). However, I can confidently say that at least 95 out of 100 newly hired engineers have never used Hack or PHP before. But these people are able to pick it up very quickly, and after just one or two weeks, they have no problem with daily programming.

How do they do it?

In fact, what they follow is exactly what I mentioned at the beginning: “Learn Python from an engineering perspective.” So specifically, how should you learn, and what should you pay special attention to during the learning process?

Understanding Different Languages: Integration is Key #

In fact, if you read, practice, and think more when learning a new language, you will find that different languages are similar. Programming languages are essentially instructions for humans to control computers, and their grammar and syntax are naturally similar.

When it comes to learning a new programming language on top of what you already know, it’s actually not that difficult. The first thing you need to do is to clearly differentiate between them. For example, when learning about conditions and loops in Python, try to recall the syntax in other languages. Also, when encountering string concatenation in Python, can you analyze its complexity? With that, can you draw connections to other languages, such as Java, and identify their similarities and differences?

In addition to being able to distinguish the differences between languages, we also need to be able to connect and apply them flexibly. For example, the classic “two questions about programming languages”:

  • Do you understand the characteristics of each programming language you have learned?

  • Can you choose the appropriate programming language based on different product requirements?

Let’s take Python as an example. One of its advantages is its excellence in data analysis, which is widely used in fields such as artificial intelligence and machine learning. For instance, TensorFlow, a framework used in machine learning, is written in Python. However, when it comes to low-level matrix operations, it still relies on C++ because of its speed and higher efficiency.

In fact, many companies operate in this way, where server-side development is based on Python, while the underlying infrastructure depends on C++. This is a typical case of “choosing different languages for different needs”. After all, even a difference of only tens to hundreds of milliseconds in speed is crucial for companies and user experience.

The Only Language, Step by Step #

Of course, if Python is the first programming language you are learning, there is no need to worry. We know that, although both serving as bridges for human-machine interaction, Python has simpler syntax compared to mainstream languages like C++ and Java. It is also closer to English and more friendly to newcomers in the programming world, which is its notable advantage. In this case, what you need to do is to focus on Python as a language, clarify your learning priorities, and learn progressively at a steady pace.

Based on my years of learning and working experience, I have summarized the learning priorities of programming languages into the following three steps. You can follow these steps regardless of whether you have a foundation in other languages, and advance steadily.

Step 1: Lay the Foundation and Practice Diligently #

For any programming language, its scope is quite extensive, ranging from basic variable assignment and conditional loops to concurrent programming, web development, and so on. I believe there are hardly any books on the market that can cover everything.

Therefore, I suggest that once you have grasped the necessary foundation, you should start getting more hands-on experience. Don’t wait until you have finished learning everything from textbooks, because by then you will find that you seem to have forgotten a lot of things that you had just managed to remember. Computer science is a discipline that emphasizes practical skills, so the earlier and more diligently you practice, the better.

However, what exactly constitutes the necessary foundation? Taking Python as an example, if you can understand variable assignment, basic data types, conditional and looping statements, and the usage of functions, then you have reached the minimum standard for the first step, and you should start practicing more outside of class.

For example, you can try coding a simple calculator on your own. This is probably the first small project that most programmers work on. Can your program check whether the input is valid and return the correct result after the user inputs numbers and operators?

You may encounter many problems in the process of working on this small project. My suggestion is to search for answers on Stack Overflow when you come across something you don’t understand. This way, you can also read other people’s excellent code and learn from their ideas, which will definitely help you in your learning. Of course, if you can’t solve a problem, you can also write it in the comments, and we can solve it together.

Step 2: Code Standards, Essential #

Indeed, learning programming emphasizes speed and efficiency. However, at the same time, please do not neglect the necessary coding standards for each language. When you are just starting to practice coding, you may omit writing unit tests, but it wouldn’t be acceptable to have hundreds of lines of code without a single function, simply writing from top to bottom, right? You can skip some optional comments, but you certainly can’t condense multiple lines of code into one line, right?

For example, let’s take a look at this line of code:

v.A(param1, param2, param3).B(param4, param5).C(param6, param7).D()

Obviously, writing like this is very unscientific, so it should be split into multiple lines:

v.A(param1, param2, param3) \  # The '\' character indicates line continuation
 .B(param4, param5) \
 .C(param6, param7) \
 .D()

Another example is that although there is some discretion regarding variable and function naming, they must be meaningful. If you take shortcuts and simply name variables as v1, v2, v3, and name functions as func1, func2, func3, and so on, it not only makes it difficult for others to understand, but it also becomes a burden for yourself to maintain in the future.

An excellent programmer always follows the coding standards of the programming language. For example, engineers at Facebook must have their code reviewed by others before it can be submitted. If there are examples of not following the code standards, even if it’s just the naming of a function or a variable, we would ask the original author to make modifications. Strict adherence to standards can ensure the code quality of the codebase.

Step 3: Development experience for qualitative breakthroughs #

To truly master Python or any other programming language, it is essential to have experience developing medium to large-scale projects. It is through practical experience that you can rise higher and see further.

For example, we use search engines every day, but do you understand the server-side implementation of a search engine? This is a typical object-oriented design, where you need to define a series of related classes and functions. You need to consider multiple aspects such as product requirements, code complexity, efficiency, and readability. Additionally, after deployment, various optimizations are required.

Of course, in this column, I can’t guide you to complete a practical product with hundreds of millions of users, but I will share my development experience from these years with you. Through the case study of quantitative trading, I will guide you into the “advanced battlefield” and help you master the necessary development knowledge.

Finally, I have specially created a knowledge map for learning Python for you. It covers the most frequently used core knowledge of Python, and most of the content will be discussed in this column. You can save or print it out as a learning reference.

Today, I have shared with you the learning methods and considerations for Python. In fact, these perspectives are not only applicable to Python but also can help you learn any other programming language. I hope you will keep them in mind. In the upcoming lessons, I will guide you step by step to ultimately become a Python expert.

So, do you have any difficulties or insights regarding learning Python or any other programming language? Feel free to communicate with me in the comments section!