The Python Conceptual Hierarchy

来源:互联网 发布:linux下源码安装mysql 编辑:程序博客网 时间:2024/05/17 11:07
Before we get to the code, let’s first establish a clear picture of how this chapter fits into the overall Python picture. From a more concrete perspective, Python programs can be decomposed into modules, statements, expressions, and objects, as follows:

1. Programs are composed of modules.


2. Modules contain statements.


3. Statements contain expressions.


4. Expressions create and process objects.


Traditional introductions to programming often stress its three pillars of sequence(“Do this, then that”),  selection(“Do this if that is true”), and repetition(“Do this many times”). Python has tools in all three categories, along with some for definition—of functions and classes. These themes may help you organize your thinking early on, but they are a bit artificial and simplistic. Expressions such as comprehensions, for example, are both repetition and selection; some of these terms have other meanings in Python; and many later concepts won’t seem to fit this mold at all. In Python, the more strongly unifying principle is  objects, and what we can do with them. To see why, read on.

摘至:<<Learning Python>> 5th Edition

0 0
原创粉丝点击