2.1. "Programming Python: The Short Story"

2.1. "Python编程: 小故事"

If you are like most people, when you pick up a book as large as this one, you'd like to know a little about what you're going to be learning before you roll up your sleeves. That's what this chapter is forit provides a demonstration of some of the kinds of things you can do with Python, before getting into the details. You won't learn much here, and if you're looking for explanations of the tools and techniques applied in this chapter, you'll have to read on to later parts of the book. The point here is just to whet your appetite, review a few Python basics, and preview some of the topics to come.

如果你和大多数人一样, 在拿起这么大一本书开始埋头阅读前, 想大概了解一下书的主要内容的话, 那这一章就是你要的了. 本章演示了一些你能用Python所做的事情, 但没有详细解释. 你不会在这一章学到太多东西, 如果你想了解本章所涉及的工具和技术的详细说明, 你就必需继续阅读本书后面的章节. 在这儿, 只是激起你的兴趣,回顾一些Python的基础, 预览一些本书的内容.

To do this, I'll pick a fairly simple application task constructing a database of records and migrate it through multiple steps: interactive coding, command-line tools, console interfaces, GUIs, and simple web-based interfaces. Along the way, we'll also peek at concepts such as data representation, object persistence, and object-oriented programming (OOP); I'll mention some alternatives that we'll revisit later in the book; and I'll review some core Python ideas that you should be aware of before reading this book. Ultimately, we'll wind up with a database of Python class instances, which can be browsed and changed from a variety of interfaces.

为了这个目的, 我选了一个相当简单的任务: 构造一个数据库, 并一步步改进它, 从交互式编码, 命令行工具, 终端界面, 图形用户界面, 到简单的Web界面. 期间, 我们会看到一些概念, 如数据呈现, 对象持久化, 和面向对象编程(OOP); 我会提到一些其它的实现方法, 这些方法会在本书后面章节中再次出现; 我还会回顾一些核心的Python概念, 这些知识是你在阅读本书之前应该了解的. 最终, 我们会得到一个Python类实例的数据库, 它可以通过多种接口来浏览和修改.

I'll cover additional topics in this book, of course, but the techniques you will see here are representative of some of the domains we'll explore later. And again, if you don't completely understand the programs in this chapter, don't worry because you shouldn't not yet anyway. This is just a Python demo. We'll fill in the details soon enough. For now, let's start off with a bit of fun.

我还会涉及到其它内容, 当然, 你在这儿看到的技术都是后面内容的代表. 如果你在本章中有看不懂的程序, 你不用担心. 这只是一个Python的例子. 我们很快就讲到所有的细节. 现在, 让我们愉快的开始吧.