Think Python Glossary

一、The way of the program
problem solving: The process of formulating a problem, ?nding a solution, and expressing the solution.
high-level language: A programming language like Python that is designed to be easy for humans to read and write.
low-level language: A programming language that is designed to be
easy for a computer to execute; also called “machine language” or
“assembly language.”
portability: A property of a program that can run on more than one kind of computer.
interpret: To execute a program in a high-level language by translating it one line at a time.
compile: To translate a program written in a high-level language
into a low-level language all at once, in preparation for later
execution.
source code: A program in a high-level language before being compiled.
object code: The output of the compiler after it translates the program.
executable: Another name for object code that is ready to be executed.
prompt: Characters displayed by the interpreter to indicate that it is ready to take input from the user.
script: A program stored in a ?le (usually one that will be interpreted).
program: A set of instructions that speci?es a computation.
algorithm: A general process for solving a category of problems.
bug: An error in a program.
debugging: The process of ?nding and removing any of the three kinds of programming errors.
syntax: The structure of a program.
syntax error: An error in a program that makes it impossible to parse (and therefore impossible to interpret).
exception: An error that is detected while the program is running.
semantics: The meaning of a program.
semantic error: An error in a program that makes it do something other than what the programmer intended.
natural language: Any one of the languages that people speak that evolved naturally.
formal language: Any one of the languages that people have
designed for speci?c purposes, such as representing mathematical ideas
or computer programs; all programming languages are formal languages.
token: One of the basic elements of the syntactic structure of a program, analogous to a word in a natural language.
parse: To examine a program and analyze the syntactic structure.
print statement: An instruction that causes the Python interpreter to display a value on the screen.

二、Variables, expressions and statements
value: One of the basic units of data, like a number or string, that a program manipulates.
type: A category of values. The types we have seen so far are
integers (type int),?oating-point numbers (type float), and strings
(type str).
integer: A type that represents whole numbers.
?oating-point: A type that represents numbers with fractional parts.
string: A type that represents sequences of characters.
variable: A name that refers to a value.
statement: A section of code that represents a command or action.
So far, the statements we have seen are assignments and print
statements.
assignment: A statement that assigns a value to a variable.
state diagram: A graphical representation of a set of variables and the values they refer to.
keyword: A reserved word that is used by the compiler to parse a
program; you cannot use keywords like if, def, and while as variable
names.
operator: A special symbol that represents a simple computation like addition, multiplication, or string concatenation.
operand: One of the values on which an operator operates.
?oor division: The operation that divides two numbers and chops off the fraction part.
expression: A combination of variables, operators, and values that represents a single result value.
evaluate: To simplify an expression by performing the operations in order to yield a single value.
rules of precedence: The set of rules governing the order in which expressions involving multiple operators and operands are evaluated.
concatenate: To join two operands end-to-end.
comment: Information in a program that is meant for other
programmers (or anyone reading the source code) and has no effect on the
execution of the program.

三、Functions
function: A named sequence of statements that performs some
useful operation.Functions may or may not take arguments and may or may
not produce a result.
function de?nition: A statement that creates a new function, specifying its name, parameters, and the statements it executes.
function object: A value created by a function de?nition. The name of the function is a variable that refers to a function object.
header: The ?rst line of a function de?nition.
body: The sequence of statements inside a function de?nition.
parameter: A name used inside a function to refer to the value passed as an argument.
function call: A statement that executes a function. It consists of the function name followed by an argument list.
argument: A value provided to a function when the function is
called. This value is assigned to the corresponding parameter in the
function.
local variable: A variable de?ned inside a function. A local variable can only be used inside its function.
return value: The result of a function. If a function call is used as an expression, the return value is the value of the expression.
fruitful function: A function that returns a value.
void function: A function that doesn’t return a value.
module: A ?le that contains a collection of related functions and other de?nitions.
import statement: A statement that reads a module ?le and creates a module object.
module object: A value created by an import statement that provides access to the values de?ned in a module.
dot notation: The syntax for calling a function in another module
by specifying the module name followed by a dot (period) and the
function name.
composition: Using an expression as part of a larger expression, or a statement as part of a larger statement.
?ow of execution: The order in which statements are executed during a program run.
stack diagram: A graphical representation of a stack of functions, their variables, and the values they refer to.
frame: A box in a stack diagram that represents a function call. It contains the local variables and parameters of the function.
traceback: A list of the functions that are executing, printed when an exception occurs.

四、Case study: interface design
instance: A member of a set. The TurtleWorld in this chapter is a member of the set of TurtleWorlds.
loop: A part of a program that can execute repeatedly.
encapsulation: The process of transforming a sequence of statements into a function de?nition.
generalization: The process of replacing something unnecessarily
speci?c (like a number) with something appropriately general (like a
variable or parameter).
interface: A description of how to use a function, including the name and descriptions of the arguments and return value.
development plan: A process for writing programs.
docstring: A string that appears in a function de?nition to document the function’s interface.

五、Conditionals and recursion
modulus operator: An operator, denoted with a percent sign (%),
that works on integers and yields the remainder when one number is
divided by another.
boolean expression: An expression whose value is either True or False.
comparison operator: One of the operators that compares its operands: ==, !=, >, <,>=, and <=.
logical operator: One of the operators that combines boolean expressions: and, or,and not.
conditional statement: A statement that controls the ?ow of execution depending on some condition.
condition: The boolean expression in a conditional statement that determines which branch is executed.
compound statement: A statement that consists of a header and a
body. The header ends with a colon (:). The body is indented relative to
the header.
body: The sequence of statements within a compound statement.
branch: One of the alternative sequences of statements in a conditional statement.
chained conditional: A conditional statement with a series of alternative branches.
recursion: The process of calling the function that is currently executing.
base case: A conditional branch in a recursive function that does not make a recursive call.
in?nite recursion: A function that calls itself recursively
without ever reaching the base case. Eventually, an in?nite recursion
causes a runtime error.

六、Fruitful functions
temporary variable: A variable used to store an intermediate value in a complex calculation.
dead code: Part of a program that can never be executed, often because it appears after a return statement.
None: A special value returned by functions that have no return statement or a return statement without an argument.
incremental development: A programdevelopment plan intended to avoid debugging by adding and testing only a small amount of code at a time.
scaffolding: Code that is used during program development but is not part of the ?nal version.
guardian: A programming pattern that uses a conditional statement to check for and handle circumstances that might cause an error.

七、Iteration
multiple assignment: Making more than one assignment to the same variable during the execution of a program.
update: An assignment where the new value of the variable depends on the old.
initialize: An assignment that gives an initial value to a variable that will be updated.
increment: An update that increases the value of a variable (often by one).
decrement: An update that decreases the value of a variable.
iteration: Repeated execution of a set of statements using either a recursive function call or a loop.
in?nite loop: A loop in which the terminating condition is never satis?ed.

八、Strings
object: Something a variable can refer to. For now, you can use “object” and “value”interchangeably.
sequence: An ordered set; that is, a set of values where each value is identi?ed by an integer index.
item: One of the values in a sequence.
index: An integer value used to select an item in a sequence, such as a character in a string.
slice: A part of a string speci?ed by a range of indices.
empty string: A string with no characters and length 0, represented by two quotation marks.
immutable: The property of a sequence whose items cannot be assigned.
traverse: To iterate through the items in a sequence, performing a similar operation on each.
search: A pattern of traversal that stops when it ?nds what it is looking for.
counter: A variable used to count something, usually initialized to zero and then incremented.
method: A function that is associated with an object and called using dot notation.
invocation: A statement that calls a method.

九、Case study: word play
?le object: A value that represents an open ?le.
problem recognition: A way of solving a problem by expressing it as an instance of a previously-solved problem.
special case: A test case that is atypical or non-obvious (and less likely to be handled correctly).

十、Lists
list: A sequence of values.
element: One of the values in a list (or other sequence), also called items.
index: An integer value that indicates an element in a list.
nested list: A list that is an element of another list.
list traversal: The sequential accessing of each element in a list.
mapping: A relationship in which each element of one set
corresponds to an element of another set. For example, a list is a
mapping from indices to elements.
accumulator: A variable used in a loop to add up or accumulate a result.
reduce: A processing pattern that traverses a sequence and accumulates the elements into a single result.
map: A processing pattern that traverses a sequence and performs an operation on each element.
?lter: A processing pattern that traverses a list and selects the elements that satisfy some criterion.
object: Something a variable can refer to. An object has a type and a value.
equivalent: Having the same value.
identical: Being the same object (which implies equivalence).
reference: The association between a variable and its value.
aliasing: A circumstance where two variables refer to the same object.
delimiter: A character or string used to indicate where a string should be split.

十一、Dictionaries
dictionary: A mapping from a set of keys to their corresponding values.
key-value pair: The representation of the mapping from a key to a value.
item: Another name for a key-value pair.
key: An object that appears in a dictionary as the ?rst part of a key-value pair.
value: An object that appears in a dictionary as the second part
of a key-value pair.This is more speci?c than our previous use of the
word “value.”
implementation: A way of performing a computation.
hashtable: The algorithm used to implement Python dictionaries.
hash function: A function used by a hashtable to compute the location for a key.
hashable: A type that has a hash function. Immutable types like
integers, ?oats and strings are hashable; mutable types like lists and
dictionaries are not.
lookup: A dictionary operation that takes a key and ?nds the corresponding value.
reverse lookup: A dictionary operation that takes a value and ?nds one or more keys that map to it.
singleton: A list (or other sequence) with a single element.
call graph: A diagram that shows every frame created during the execution of a program, with an arrow from each caller to each callee.
histogram: A set of counters.
hint: A computed value stored to avoid unnecessary future computation.
global variable: A variable de?ned outside a function. Global variables can be accessed from any function.

十二、Tuples
tuple: An immutable sequence of elements.
tuple assignment: An assignment with a sequence on the right side
and a tuple of variables on the left. The right side is evaluated and
then its elements are assigned to the variables on the left.

十三、Case study: data structure selection
DSU: Abbreviation of “decorate-sort-undecorate,” a processing
pattern that involves building a list of tuples, sorting, and (often)
extracting part of the result.
deterministic: Pertaining to a program that does the same thing each time it runs,given the same inputs.
pseudorandom: Pertaining to a sequence of numbers that appear to be random, but are generated by a deterministic program.
default value: The value given to an optional parameter if no argument is provided.
override: To replace a default value with an argument.
data structure: Any collection of values, including sequences and dictionaries.
benchmarking: The process of choosing between data structures by
implementing alternatives and testing them on a sample of the possible
inputs.

十四、Files
persistent: Pertaining to a program that runs inde?nitely and keeps at least some of its data in permanent storage.
format operator: An operator, %, that takes a format string and a
tuple and generates a string that includes the elements of the tuple
formatted as speci?ed by the format string.
format string: A string, used with the format operator, that contains format sequences.
format sequence: A sequence of characters in a format string, like %d that speci?es how a value should be formatted.
text ?le: A sequence of characters stored in non-volatile storage like a hard drive.
directory: A named collection of ?les, also called a folder.
path: A string that identi?es a ?le.
relative path: A path that starts from the current directory.
absolute path: A path that starts from the topmost directory in the ?le system.
catch: To prevent an exception from terminating a program using the try and except statements.
database: A ?le whose contents are organized like a dictionary with keys that correspond to values.

十五、Classes and objects
class: A user-de?ned type. A class de?nition creates a new class object.
class object: An object that contains information about a user-de?ned time. The class object can be used to create instances of the type.
instance: An object that belongs to a class.
attribute: One of the named values associated with an object.
shallow copy: To copy the contents of an object, including any
references to embedded objects; implemented by the copy function in the
copy module.
deep copy: To copy the contents of an object as well as any
embedded objects, and any objects embedded in them, and so on;
implemented by the deepcopy function in
the copy module.
object diagram: A diagram that shows objects, their attributes, and the values of the attributes.

十六、Classes and functions
prototype and patch: A development plan that involves writing a rough draft of a program, testing, and correcting errors as they are found.
planned development: A development plan that involves high-level
insight into the problem and more planning than incremental development
or prototype development.
pure function: A function that does not modify any of the objects it receives as arguments. Most pure functions are fruitful.
modi?er: A function that changes one or more of the objects it receives as arguments.Most modi?ers are fruitless.
functional programming style: A style of program design in which the majority of functions are pure.

十七、Classes and methods
object-oriented language: A language that provides features, such as user-de?ned classes and inheritance, that facilitate object-oriented programming.
object-oriented programming: A style of programming in which data and the operations that manipulate it are organized into classes and methods.
method: A function that is de?ned inside a class de?nition and is invoked on instances of that class.
subject: The object a method is invoked on.
operator overloading: Changing the behavior of an operator like + so it works with a user-de?ned type.
type-based dispatch: A programming pattern that checks the type of an operand and invokes different functions for different types.
polymorphic: Pertaining to a function that can work with more than one type.

十八、Inheritance
encode: To represent one set of values using another set of values by constructing a mapping between them.
class attribute: An attribute associated with a class object. Class attributes are de?ned inside a class de?nition but outside any method.
instance attribute: An attribute associated with an instance of a class.
veneer: A method or function that provides a different interface to another function without doing much computation.
inheritance: The ability to de?ne a new class that is a modi?ed version of a previously de?ned class.
parent class: The class from which a child class inherits.
child class: A new class created by inheriting from an existing class; also called a “subclass.”
IS-A relationship: The relationship between a child class and its parent class.
HAS-A relationship: The relationship between two classes where instances of one class contain references to instances of the other.
class diagram: A diagram that shows the classes in a program and the relationships between them.
multiplicity: A notation in a class diagram that shows, for a
HAS-A relationship, how many references there are to instances of
another class.

十九、Case study: Tkinter
GUI: A graphical user interface.
widget: One of the elements that makes up a GUI, including buttons, menus, text entry ?elds, etc.
option: A value that controls the appearance or function of a widget.
keyword argument: An argument that indicates the parameter name as part of the function call.
callback: A function associated with a widget that is called when the user performs an action.
bound method: A method associated with a particular instance.
event-driven programming: A style of programming in which the ?ow of execution is determined by user actions.
event: A user action, like a mouse click or key press, that causes a GUI to respond.
event loop: An in?nite loop that waits for user actions and responds.
item: A graphical element on a Canvas widget.
bounding box: A rectangle that encloses a set of items, usually speci?ed by two opposing corners.
pack: To arrange and display the elements of a GUI.
geometry manager: A system for packing widgets.
binding: An association between a widget, an event, and an event
handler. The event handler is called when the the event occurs in the
widget.

时间: 2024-07-28 21:01:47

Think Python Glossary的相关文章

Learn Python the Hard Way--Exercise 46

0. 缘起 <Learn Python the Hard Way>Exercise 46 要求安装四个python package pip, distribute, nose, virtualenv,(原书作者特别提醒: Do not just donwload these packages and install them by hand. Instead see how other people recommend you install these packages and use th

Python 2.7.8 学习笔记(001)python manuals/the python tutorial

从今天开始学python, python有点意思,第一感觉界面和matlab有点像. 手头没有什么资料,就从安装好了的一个python 2.7.8,里面有个英文版的manual,那就只好从这里开始吧,为什么不是中文版的呢??那就边看边翻译吧. python漫游指南:python是一种简单易学功能强大的编程语言.它有高效的数据结构和简单但有效的面向对象编程方法.python优雅的语法和动态拼写以及解释特性,使得它在许多平台上成为一种理想的脚本语言和快速程序开发工具. python的解释器和扩展标准

python之 可迭代 迭代器 生成器

0. 1.总结 (1) iterable 可迭代(对象) 能力属性 指一个对象能够一次返回它的一个成员,for i in a_list 而不需要通过下标完成迭代. 例子包括所有序列类型(list, str, tuple), 以及 dict, file, 还包括定义了 __iter__() 或 __getitem__() 方法的类实例. iterator 迭代器 具体实现 代表数据流的对象.重复调用迭代器的 next() (python3为 __next__()) 方法将依次返回流中的项.当没有更

python 2.7 中文教程及自动化测试介绍(1)

简介 Python是一门简单易学,功能强大的编程语言.它具有高效的高层次数据结构,简单但有效的方式支持面向对象编程,语法优雅,动态类型,解释执行.使之成为多数平台上很多领域的脚本和快速应用开发的理想语言. Python解释器及其丰富的标准库的源码或者二进制版本可以从http://www.python.org/免费获取和转发.该还包含很多免费的第三方Python模块.程序.工具的发布链接及附加文档. Python的解释器很容易用C或C++(或其他c可以调用的语言)扩展新功能和数据类型. Pytho

python官方文档

Tutorialstart here Library Referencekeep this under your pillow Language Referencedescribes syntax and language elements Python Setup and Usagehow to use Python on different platforms Python HOWTOsin-depth documents on specific topics Extending and E

我要翻译《Think Python》-002 贡献列表 &amp; 目录部分

PDF源文件地址 :  http://www.greenteapress.com/thinkpython/thinkpython.pdf 贡献列表 自从本书诞生之后,有超过上百个目光敏锐且有想法的读者给我发来了许多建议并指出了一些需要修正的地方.他们的热情和无私的奉献给了我巨大的帮助.如果你有任何建议或者发现需要修正的地方,请发邮件至:[email protected].如果您的建议被采纳,您的大名将会出现在我们的贡献人员列表(除非你本人过于低调拒绝承认).如果您发现文中的错误内容,敬请提供一下

Python学习1-Python和Pycharm的下载与安装

本文主要介绍Python的下载安装和Python编辑器Pycharm的下载与安装. 一.Python的下载与安装 1.下载 到Python官网上下载Python的安装文件,进入网站后显示如下图: 网速访问慢的话可直接在这里下载:python-2.7.11.amd64 在Downloads中有对应的支持的平台,这里我们是在Windows平台下运行,所以点击Windows,出现如下: 在这里显示了Python更新的所有版本,其中最上面两行分别是Python2.X和Python3.X对应的最后更新版本

Python——深入理解urllib、urllib2及requests(requests不建议使用?)

深入理解urllib.urllib2及requests            python Python 是一种面向对象.解释型计算机程序设计语言,由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年,Python 源代码同样遵循 GPL(GNU General Public License)协议[1] .Python语法简洁而清晰,具有丰富和强大的类库. urllib and urllib2 区别 urllib和urllib2模块都做与请求URL相关的操作,但

python学习_day26_面向对象之封装

1.私有属性 (1)动态属性 在python中用双下划线开头的方式将属性隐藏起来.类中所有双下划线开头的名称,如__x都会自动变形成:_类名__x的形式.这种自动变形的特点是: a.类中定义的__x只能在内部使用,如self.__x,引用的就是变形的结果.b.这种变形其实正是针对外部的变形,在外部是无法通过__x这个名字访问到的.c.在子类定义的__x不会覆盖在父类定义的__x,因为子类中变形成了:_子类名__x,而父类中变形成了:_父类名__x,即双下滑线开头的属性在继承给子类时,子类是无法覆