Aiti Tribe Stories (30): My Love-Hate Relationship with Python

Aiti Tribe Stories (30): My Love-Hate Relationship with Python

[51CTO.com original article] Taniey's relationship with Python was also an accident. When the company was reorganized, he and his teammates built the server with bare hands under pressure for several weeks. That's how the story of Python came about. He would fix bugs if there were any, and he would also create bugs if there were no bugs. He hopes to use his 7 years of experience in fixing bugs to encourage those who are also struggling in the Python world.

[[207273]]

Taniey·Python Development Engineer

Taniey is a typical programmer who likes to be in a daze and is a bug maker. He has dug countless pits, burying himself and his teammates.

[[207274]]

Dig a hole and run away? That’s not possible... If you can’t get away with it, then fill the hole with all your heart.

Get started with Python from the official website

Taniey’s connection with Python was also an accident. Due to the company’s reorganization, the leader pulled him and his teammates out and said: You have a few weeks to build the service, otherwise… (Haha, it’s not that serious. They will be separated into a subsidiary and all things will have to be redeveloped, but the pressure is still quite high). There is no way. If he, a die-hard fan of C++, still uses C++ for development, the service would have died out by the time it was developed. So he turned to seek other languages ​​with higher development efficiency, and that’s how he came into contact with Python.

Taniey, who changed his career path late, had never touched Python before. Others said to buy books to learn, but he didn't buy any (in fact, time was too tight and there was really no time to read books). He learned online. At that time, he found a good website, which was concise and practical, although the website was more suitable for people with other language foundations. Unfortunately, Taniey could not find the website. All he could find were some websites with systematic explanations. If you want to learn systematically, these websites are very good. Most developers are trying to make rapid breakthroughs in a short period of time, so it is better to find some practical information.

As for buying books, Taniey thinks books are good things. You can read them at any time and learn systematically. However, if you want to get first-hand information, the Python official website is the best choice. Why do I say that? Foreign websites have very organized and detailed product documentation, and the content is not too much (Python itself does not have much syntax, and many developers say that Python is concise, which is one of the reasons). You can finish reading it in a week, and it’s still in your spare time! So don’t hesitate, go and read it, and you can learn some English by the way, how great~~

Relearn Python, it's in your pocket

When learning Python, the best thing is to have projects to work on. Learning in projects is the fastest way to learn, and you can work and study at the same time (by the way, where can you find such a good environment for you to learn? That company is really kind). Now when I think about it, I was lucky to learn Python under such pressure.

It is said that Python code is concise. For beginners, it is recommended not to deliberately pursue how concise its code is. Start with complex, then simplify, and then optimize (although it is a bit irresponsible, but how many codes are formed in one go?), and use it first, especially for those who have switched from other programming languages. When you are comfortable with Python, you will see how powerful Python is.

One thing to note is that there are two major versions of Python in use now, and they are incompatible, which is a big pitfall for beginners.

1. For example, the use of print:

In Python 2 you can directly use: print "print without brackets"

In Python 3 you need to force the use of: print("print with brackets")

If you look at the two versions of print documentation, you will find that there is a note in the python2 documentation, telling you that the print without brackets is the print statement, and the print with brackets is the actual print function.

If you are interested, you can find it yourself:

Python2; Python3

2. Python 2 will stop updating in 2020, so if there are no historical issues, use Python 3. Taniey fell into this pit, fortunately Python has py2to3.

In addition, when using Python2, you must pay attention to Python string encoding, as it is easy to fall into it and get stuck.

3. Python's tabs and spaces . Because Python uses blank characters to detect scope, the use of blank characters is very important. Many people have made mistakes here. It is best to develop a good habit here, using spaces instead of tabs. Fortunately, most IDEs will automatically convert tabs and spaces, which is much more convenient.

The following lines of code: Can you tell which is a space and which is a TAB?

It becomes clearer when whitespace characters are displayed:

The best thing Taniey has learned about Python is that you don’t need to write too much. If you need something, you can always find it on PyPI.

4. IDE selection . IDE is essential for development. You can search a lot about Python IDE on the Internet. There are a lot of them. Taniey had no experience at that time, so he could only test them one by one. I won't talk about his blood and tears history of testing, but I will talk about the test results:

Developed on Windows and running on Linux, Taniey tested the following the most:

Notepad++, Visual studio PythonIDE plugin, Eclipse+PyDev, PyCharm

①Notepad++ : Yes, it is a notepad-like tool, and he actually chose this one at the beginning. He used it because it was simple, and later he had no choice but to stop using it because it was too simple. Although this tool can add many plug-ins to achieve IDE-like functions, it is still far from a real IDE.

②Visual studio PythonIDE plug-in . This plug-in is naturally integrated with Visual studio and is in line with the VS style. It was quite good when I first used it, but after using it for a long time, I found that it was full of bugs and became annoying (when Taniey used it, it was only 2.0, and what version is it now).

③PyCharm , the official website praises it very well. Taniey feels that it is just a modification of Eclipse, nothing special (don’t criticize me, everyone has their own preferences).

(Thanks to @北京-unicorn-数据 for providing the cracked version)

PyCharm cracked version, fill in License server>>

How to register PyCharm code>>

The third method is more troublesome: IntelliJ IDEA License Server Local Setup Tutorial [[207276]]

Taniey's favorite is Eclipse+PyDev . Basically, it has all the functions that developers want to use. If you are good at using Eclipse, this should not be a problem. Taniey strongly recommends it.

5. Python Enhancement Proposals (PEPs) of Python , including: pep8 Python code style specification. If you want to use Python for your project, it is recommended to read more about this pep8 specification. It is very helpful for your coding style. Reference website >>

Borrowing from Tim Peters's Zen of Python. Reference URL >>

You can find translations online, there are many.

【Written in ***】

From C++ to Python, Taniey fell more and more in love with this powerful programming language - Python. He has been developing with Python for nearly four years, mostly video service products, using Python as the interface. He dug and filled the pits by trial and error. In Taniey's words, he would fix the bugs if there were any, and he would also create bugs if there were no bugs. He hopes to use his years of experience in filling the pits to encourage those who are also struggling in the Python world.

If you are also willing to share your story, please join the 51CTO developer QQ exchange group 627843829 and contact the group owner Xiaoguan. We look forward to your wonderful story!

[51CTO original article, please indicate the original author and source as 51CTO.com when reprinting on partner sites]

<<:  Let’s talk about the process of the project from 0 to 1

>>:  Introduction to HTTPS encryption methods and their advantages and disadvantages

Recommend

BOM cost announced for the first time. Who pays for LeEco's super phone?

April 14 (Reporter Zhang Zhichang) After being aw...

Tencent Advertising Marketing: Pay-per-view for games

1. First , let’s take a look at what is pay-per- ...

The magic of clay! A new breakthrough in the method of stopping bleeding

Produced by: Science Popularization China Author:...

Build a secure app! iOS security series: HTTPS

[[144627]] How to create a secure App? This is a ...

Didi sets up driverless lab in Silicon Valley near Apple headquarters

According to AppleInsider, Didi launched its own ...

How to write popular notes on Xiaohongshu?

"Hey, my notes have had poor traffic recentl...

Nature sub-journal: Subverting cognition! Do we really need to be "brainwashed"?

Produced by: Science Popularization China Author:...