How to systematically teach yourself the Python language

伊谢尔伦
Release: 2016-12-02 11:58:46
Original
1139 people have browsed it

With zero basic knowledge, if you want to learn a language to enrich yourself, Python is a good choice because it is simple, beautiful and easy to use. So how to systematically learn Python by yourself?

Some people really want to learn Python well. On the one hand, they are entangled in trivial matters and have never been able to get started. On the other hand, they are worried that the cost of learning is too high, and they are silently giving up?

Fortunately, Python is a beginner-friendly programming language, and you don’t have to spend too much time and energy to fully master it.

One of Python’s design philosophies is that it is simple and easy to learn, which is reflected in two aspects:

Simple and clear syntax: Compared with Ruby and Perl, its syntax features are no more or less, and most of them are simple and direct, without playing metaphysics.

There are many entry points: Python allows you to do many things, including scientific computing and data analysis, crawlers, web sites, games, command line utilities, etc. There is always one that interests you and is willing to invest time.

No further nonsense, there is only one shortcut to learn a language: Getting Started

1. Starting stage

Any programming language contains two parts: hard knowledge and soft knowledge. The main task in the starting stage is to master Hard knowledge. Any programming language contains two parts: hard knowledge and soft knowledge. The main task in the initial stage is to master hard knowledge.

1. Hard knowledge

"Hard knowledge" refers to the syntax, algorithms and data structures of programming languages, programming paradigms, etc., such as variables and types, loop statements, branches, functions, and classes. This part of knowledge is also universal. It seems to have mastered a kind of grammar, but in fact it has established a kind of thinking. For example, if a Java programmer is asked to learn Python, he can quickly map the object-oriented knowledge learned in Java to Python, so he can quickly master the object-oriented features of Python.
If you are new to learning programming, a reliable grammar book is very important. It may seem tedious, but it's essential for building a solid programming mindset.
The following is a list of some teaching materials suitable for beginners:

❖"Learn Python the Hard Way": http://learnpythonthehardway.org/book/
This book also explains the grammatical components of Python and comes with a lot of useful information. Practical examples, great for getting started quickly.

❖「The Hitchhiker’s Guide to Python!」:The Hitchhiker’s Guide to Python!
This guide focuses on the best practices of Python. Whether you are a Python expert or a novice, you can get great help.

❖「Python Official Documentation」: Our Documentation
Most of the questions in practice can be answered in the official documentation.

❖ Auxiliary tool: Python Tutor
A Python object visualization project that uses graphics to help you understand various concepts in Python.

Python’s philosophy:

Use one way, preferably only one way, to do one thing.

The same goes for studying. Although a variety of study materials are recommended, when actually studying, it is best to choose only one of them and stick to it.

When necessary, you may need to read books explaining data structures and algorithms. This knowledge is very helpful in understanding and using the object model in Python.


2. Soft knowledge
"Soft knowledge" refers to grammatical skills in a specific language environment, the use of class libraries, the choice of IDE, etc. Even if you don't understand this part at all and can't use it, it won't prevent you from programming, but the program you write will look a bit "silly".

The learning of this knowledge depends on the field and depth of the problem you are trying to solve. For beginners, it is easy to get lost in the initial stage, or hesitate when choosing a Python version, looking at 2.7 for a while and then switching to 3.0 for a while, or wandering in the sea of ​​class libraries, unable to extricate themselves, including Scrapy, Numpy, and Django. Try it, or participate in meaningless activities such as editor jihad, brace indentation exploration, operating system debate competition, or kneel down all day licking syntactic sugar, always thinking about how to get everything done with one line of code, or conceiving of holy A solution with perfect scores in terms of performance, security, versatility and robustness.

Many "big guys" will warn beginners to use this and that, and avoid detours. This will push beginners into real detours.
It is better to tell beginners that learning is a process that requires you to take detours and make bugs, and you can only be down-to-earth. There are no miracles, only shit.

Choose a direction and walk on first. Even if it’s dirty and ugly and you can’t walk anymore, then see if there is a better solution.

Only when you take a detour will you know the benefits of doing so, and understand why people can handwrite state machines to match but have to invent regular expressions, why process-oriented solutions can be solved but object-oriented, why I can control everything The root pointer has to automatically manage memory, why do I have to use Promise when I can nest callbacks...

More importantly, you will understand that high-level solutions are encapsulation of low-level, not any Whichever is most effective and appropriate under the circumstances.

The influx of technology is like a wave. Those old technologies that have been sealed for a long time will fade away and sooner or later they will come back. Just like the current popularity of mobile applications, mobile games and HTML5, aren't some aspects repeating the history of PCs in the past?

Therefore, don’t worry about taking the wrong path and losing your life. Perseverance and progress are the right path.

The core task in the initial stage is to master hard knowledge and properly understand soft knowledge. Only with stable roots and strong branches can we grow thick leaves and bear sweet fruits.

2. Development stage

After completing the learning of basic knowledge, you will definitely feel a sense of emptiness and doubt whether this grammar knowledge is really useful.
Yes, your suspicion is very correct. For Python to exert its value, of course it cannot stop at the syntax level.
The core task of the development stage is to “break out of Python and embrace the world”.
There will be multiple branches in front of you: scientific computing and data analysis, crawlers, web sites, games, command line utilities, etc. These are not problems that can be solved by just knowing Python syntax.
Take crawlers as an example. If you know nothing about computer networks, HTTP protocols, HTML, text encoding, and JSON, can you do this part of the job well? And your basic knowledge in the initial stage is equally important. If you even need to check the documentation on how to write loops and recursions, and you don’t even know how to implement BFS, it’s like a craftsman making a stone bench who has to think about how to use the hammer every time he lifts the hammer. Same, very inefficient.
At this stage, it is inevitable to come into contact with a large number of class libraries and read a large number of books.

°1 Class Library
"Awesome Python Project": vinta/awesome-python · GitHub
Here is a list of tool libraries that the Python community already has when you try to solve various practical problems, as shown in the figure below :

How to systematically teach yourself the Python language

You can find the class library you need according to your actual needs.
As for how to use related class libraries, the skill that must be mastered is to read the documentation. Since most documents in the open source community are written in English, students who are not good at English need to make up for it.


°2 In terms of books
Here I only list some books that I think are more helpful. For details, please read Douban’s book reviews:
Science and data analysis:
❖"Collective Intelligence Programming": Collective Intelligence Programming
❖" "The Beauty of Mathematics": The Beauty of Mathematics
❖ "Statistical Learning Methods": Statistical Learning Methods
❖ "Pattern Recognition And Machine Learning": Pattern Recognition And Machine Learning
❖ "Data Science Practice": Data Science Practice
❖ "Introduction to Data Retrieval" :Introduction to Information Retrieval
Crawler:
❖ "HTTP Definitive Guide": HTTP Definitive Guide
Web Website:
❖ "HTML & CSS Design and Build Website": HTML & CSS Design and Build Website

...

List to There is no need to continue here.
If you are smart, you will definitely find that most of the books above are not about Python, but more about professional knowledge.
In fact, the so-called "jump out of Python and embrace the world" here actually means that the combination of Python and professional knowledge can solve many practical problems. How far you can go at this stage depends more on your own professional knowledge. ​​

3. In-depth stage

At this stage, you know almost everything about Python, so you must know that Python is implemented in C language.

But how are the "dynamic features" of Python objects implemented using the relatively low-level C language that doesn't even have automatic memory management? At this time, we can no longer stay on the surface. We must bravely open the black box of Python, go deep into the language, see its history, and read its source code, only then can we truly understand its design ideas.

Here is a recommended book:
"Python Source Code Analysis": Python Source Code Analysis
This book gives a detailed explanation of the core part of the Python source code, but reading this book requires understanding of the C language memory model and pointers Have a good understanding.

In addition, Python itself is a dynamic language that combines multiple paradigms. That is to say, compared to the procedural programming of C, the functional programming such as Schema and Haskell, and the class-based object-oriented programming of Java, it is not pure enough. In other words, the "Taoism" of programming languages ​​can only be understood to a limited extent in Python. When learning a certain programming paradigm, starting from those languages ​​that are more pure for this paradigm can have a deeper understanding and understand the roots of the Python language.

Here we recommend an open course
"Programming Paradigms": Stanford University Open Course: Programming Paradigms
The lecturer has a high-level view, starting from the representative languages ​​​​of various programming paradigms, and gives the core ideas of each programming paradigm.

It is worth mentioning that this course has a very in-depth explanation of C language, such as C language paradigms and memory management. This knowledge is also very helpful for reading Python source code.

Many of Python’s best practices are hidden in well-known frameworks and libraries, such as Django, Tornado, etc. Digging for gold in their source code is also a good option.

¶ Final words
Everyone’s path to learning programming is different. In fact, most of them arrive at the same destination through different paths. There are no people who are lost, only people who cannot persevere. Although it sounds a bit chicken soup, it is true.


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