课程: Python Essential Training

The Zen of Python - Python教程

课程: Python Essential Training

The Zen of Python

- Python has been around for 30 years, and its popularity only seems to grow as it ages. Python isn't clumsy or random, as JavaScript. It's an elegant language for a more civilized age. For example, the syntax, or way you write the code to call one function, is probably the same way you'd write the code to call a similar function. The designers of Python tried, and in my opinion succeeded, in keeping the language simple and consistent. And Python isn't just a programming language for beginners. I use it every day at my job to build huge complex systems. Because when you're dealing with a lot of complexity, the last thing you want is to complicate things. And that's where Python really shines. They even have a kind of mission statement to drive this point, hidden in an Easter egg called import this. Let's go to the code. Open up any terminal and type Python to enter the Python command prompt like we did previously. You should see two greater than symbols letting you know that it's ready for a line of Python. And now we're going to type import this. Import is a good command to know. It says, go fetch me a module so I can use it, and this is the name of the module we're importing. We'll learn more about the import statements later, but if you type import this and then hit enter, you're going to get the following document printed out. Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. See what I mean? Code gets complex enough on its own. I'm not going to read this whole thing, but consider this your first sort of mini challenge. Open up a terminal, type import this and see what happens. Even if you don't fully understand every word or statement this document is making, I think you'll probably get the general sentiment. And by the way, if you go back and reread this when you've reached the end of this course, I can almost guarantee that every part of it will make perfect sense, just like Python itself.

内容