English-010 DiveIntoPython
1.This chapter covers one of Python's strengths: introspection.
introspection [,intrəu'spekʃən] n. 内省;反思;自省
2.Don't worry if the rest of the code looks intimidating; you'll learn all about it throughout this chapter.
intimidating adj. 吓人的
3.The info function has a multi-line doc string that succinctly describes the function's purpose. Note that no return value is mentioned; this function will be used solely for its effects, rather than its value.
succinct [sək'siŋkt, sə's-] adj. 简洁的;简明的;紧身的
solely ['səulli] adv. 单独地,唯一地
4.By default the output is formatted to be easy to read. Multi-line doc strings are collapsed into a single long line, but this option can be changed by specifying 0 for the collapse argument. If the function names are longer than 10 characters, you can specify a larger value for the spacing argument to make the output easier to read.
collapse [kə'læps] vi. 倒塌;瓦解;暴跌
5.This looks totally whacked until you realize that arguments are simply a dictionary.
whacked [hwækt] adj. 疲惫不堪的,精疲力竭的
6.Python has a small set of extremely useful built-in functions. All other functions are partitioned off into modules. This was actually a conscious design decision, to keep the core language from getting bloated like other scripting languages
partitioned adj. 分区的;分割的;分段的 partition off 分隔成;隔开
partition [pɑ:'tiʃən] n. 分割;划分,分开;隔离物;隔墙 vt. 分割;区分;分隔
conscious ['kɔnʃəs] adj. 意识到的;故意的;神志清醒的
bloated ['bləutid] adj. 傲慢的;发胀的,浮肿的
7.The str coerces data into a string. Every datatype can be coerced into a string.
coerce [kəu'ə:s] vt. 强制,迫使 coerce into: 强迫...做
8.The functions in the string module are deprecated (although many people still use the join function), but the module contains a lot of useful constants like this string.punctuation, which contains all the standard punctuation characters.
punctuation [,pʌŋktju'eiʃən] n. 标点;标点符号
9.Python comes with excellent reference manuals, which you should peruse thoroughly to learn all the modules Python has to offer. But unlike most languages, where you would find yourself referring back to the manuals or man pages to remind yourself how to use these modules, Python is largely self-documenting.
peruse [pə'ru:z] vt. 详细考察;精读
10.In case it hasn't sunk in just how incredibly useful this is, try this: the return value of getattr is the method, which you can then call just as if you had said li.append("Moe") directly. But you didn't call the function directly; you specified the function name as a string instead.
sunk [sʌŋk] adj. 凹陷的 sink in 渗入;完全被理解
incredibly adv. 难以置信地;非常地 incredible [in'kredəbl] adj. 难以置信的,惊人的
11.A common usage pattern of getattr is as a dispatcher. For example, if you had a program that could output data in a variety of different formats, you could define separate functions for each output format and use a single dispatch function to call the right one.
dispatcher [dis'pætʃə] n. 调度员;调度程序;分配器
variety [və'raiəti] n. 种类;多样;杂耍
12.This is a very loose coupling of strings and functions, and there is no error checking. What happens if the user passes in a format that doesn't have a corresponding function defined in statsout?
loose [lu:s] adj. 不牢固的;不精确的;宽松的;散漫的
coupling ['kʌpliŋ] n. 耦合;结合,联结
corresponding [,kɔ:ri'spɔndiŋ] adj. 通信的;一致的;相当的,相应的
13.As you know, Python has powerful capabilities for mapping lists into other lists, via list comprehensions (Section 3.6, “Mapping Lists”). This can be combined with a filtering mechanism, where some elements in the list are mapped while others are skipped entirely.
capability [,keipə'biləti] n. 性能,容量;才能,能力
mechanism ['mekənizəm] n. 机械装置;机制;技巧;原理,途径;进程
entire [in'taiə] adj. 全部的,整个的;全体的
14.The mapping expression here is simple (it just returns the value of each element), so concentrate on the filter expression.
concentrate ['kɔnsəntreit] vi. 集中;浓缩;聚集;全神贯注
15.The filter expression looks scary, but it's not. You already know about callable, getattr, and in.
scary ['skεəri, 'skæ-] adj. 引起惊慌的;胆小的;提心吊胆的
16.You do the weeding out by taking the name of each attribute/method/function and getting a reference to the real thing, via the getattr function.
weed [wi:d] vt. 除草;铲除
17.peculiar [pi'kju:ljə] adj. 特殊的;罕见的;奇怪的;独特的
18.This distinction is important if some values can have side effects.
distinction [dis'tiŋkʃən] n. 差别;区别;特性;荣誉、勋章
19.Python supports an interesting syntax that lets you define one-line mini-functions on the fly.
on the fly 在飞行中;忙忙碌碌 联机;在飞行中, 不工作, 闲混;在飞行中;真时
Programming on the fly: 程序人生
20.This is a lambda function that accomplishes the same thing as the normal function above it. Note the abbreviated syntax here: there are no parentheses around the argument list, and the return keyword is missing (it is implied, since the entire function can only be one expression). Also, the function has no name, but it can be called through the variable it is assigned to.
accomplish [ə'kʌmpliʃ, ə'kɔm-] vt. 完成;实现;达到
abbreviated [ə'bri:vi,eitid] adj. 小型的;简短的;服装超短的
implied [im'plaid] v. 意思是(包含) a. 储蓄的 adj. 含蓄的;暗指的
21.To generalize, a lambda function is a function that takes any number of arguments (including optional arguments) and returns the value of a single expression.
22.All the dominoes are in place; it's time to knock them down.
domino ['dɔminəu] n. 多米诺骨牌;面具;化装外衣
23.The next piece of the puzzle is the use of str around the doc string.
24.ljust pads the string with spaces to the given length.
pad [[pæd]] vt. 填补;走
25.If the given length is smaller than the length of the string, ljust will simply return the string unchanged. It never truncates the string.
truncate ['trʌŋkeit, trʌŋ'keit, 'trʌŋk-] vt. 把…截短;缩短;[物]使成平面
1.This chapter covers one of Python's strengths: introspection.
introspection [,intrəu'spekʃən] n. 内省;反思;自省
2.Don't worry if the rest of the code looks intimidating; you'll learn all about it throughout this chapter.
intimidating adj. 吓人的
3.The info function has a multi-line doc string that succinctly describes the function's purpose. Note that no return value is mentioned; this function will be used solely for its effects, rather than its value.
succinct [sək'siŋkt, sə's-] adj. 简洁的;简明的;紧身的
solely ['səulli] adv. 单独地,唯一地
4.By default the output is formatted to be easy to read. Multi-line doc strings are collapsed into a single long line, but this option can be changed by specifying 0 for the collapse argument. If the function names are longer than 10 characters, you can specify a larger value for the spacing argument to make the output easier to read.
collapse [kə'læps] vi. 倒塌;瓦解;暴跌
5.This looks totally whacked until you realize that arguments are simply a dictionary.
whacked [hwækt] adj. 疲惫不堪的,精疲力竭的
6.Python has a small set of extremely useful built-in functions. All other functions are partitioned off into modules. This was actually a conscious design decision, to keep the core language from getting bloated like other scripting languages
partitioned adj. 分区的;分割的;分段的 partition off 分隔成;隔开
partition [pɑ:'tiʃən] n. 分割;划分,分开;隔离物;隔墙 vt. 分割;区分;分隔
conscious ['kɔnʃəs] adj. 意识到的;故意的;神志清醒的
bloated ['bləutid] adj. 傲慢的;发胀的,浮肿的
7.The str coerces data into a string. Every datatype can be coerced into a string.
coerce [kəu'ə:s] vt. 强制,迫使 coerce into: 强迫...做
8.The functions in the string module are deprecated (although many people still use the join function), but the module contains a lot of useful constants like this string.punctuation, which contains all the standard punctuation characters.
punctuation [,pʌŋktju'eiʃən] n. 标点;标点符号
9.Python comes with excellent reference manuals, which you should peruse thoroughly to learn all the modules Python has to offer. But unlike most languages, where you would find yourself referring back to the manuals or man pages to remind yourself how to use these modules, Python is largely self-documenting.
peruse [pə'ru:z] vt. 详细考察;精读
10.In case it hasn't sunk in just how incredibly useful this is, try this: the return value of getattr is the method, which you can then call just as if you had said li.append("Moe") directly. But you didn't call the function directly; you specified the function name as a string instead.
sunk [sʌŋk] adj. 凹陷的 sink in 渗入;完全被理解
incredibly adv. 难以置信地;非常地 incredible [in'kredəbl] adj. 难以置信的,惊人的
11.A common usage pattern of getattr is as a dispatcher. For example, if you had a program that could output data in a variety of different formats, you could define separate functions for each output format and use a single dispatch function to call the right one.
dispatcher [dis'pætʃə] n. 调度员;调度程序;分配器
variety [və'raiəti] n. 种类;多样;杂耍
12.This is a very loose coupling of strings and functions, and there is no error checking. What happens if the user passes in a format that doesn't have a corresponding function defined in statsout?
loose [lu:s] adj. 不牢固的;不精确的;宽松的;散漫的
coupling ['kʌpliŋ] n. 耦合;结合,联结
corresponding [,kɔ:ri'spɔndiŋ] adj. 通信的;一致的;相当的,相应的
13.As you know, Python has powerful capabilities for mapping lists into other lists, via list comprehensions (Section 3.6, “Mapping Lists”). This can be combined with a filtering mechanism, where some elements in the list are mapped while others are skipped entirely.
capability [,keipə'biləti] n. 性能,容量;才能,能力
mechanism ['mekənizəm] n. 机械装置;机制;技巧;原理,途径;进程
entire [in'taiə] adj. 全部的,整个的;全体的
14.The mapping expression here is simple (it just returns the value of each element), so concentrate on the filter expression.
concentrate ['kɔnsəntreit] vi. 集中;浓缩;聚集;全神贯注
15.The filter expression looks scary, but it's not. You already know about callable, getattr, and in.
scary ['skεəri, 'skæ-] adj. 引起惊慌的;胆小的;提心吊胆的
16.You do the weeding out by taking the name of each attribute/method/function and getting a reference to the real thing, via the getattr function.
weed [wi:d] vt. 除草;铲除
17.peculiar [pi'kju:ljə] adj. 特殊的;罕见的;奇怪的;独特的
18.This distinction is important if some values can have side effects.
distinction [dis'tiŋkʃən] n. 差别;区别;特性;荣誉、勋章
19.Python supports an interesting syntax that lets you define one-line mini-functions on the fly.
on the fly 在飞行中;忙忙碌碌 联机;在飞行中, 不工作, 闲混;在飞行中;真时
Programming on the fly: 程序人生
20.This is a lambda function that accomplishes the same thing as the normal function above it. Note the abbreviated syntax here: there are no parentheses around the argument list, and the return keyword is missing (it is implied, since the entire function can only be one expression). Also, the function has no name, but it can be called through the variable it is assigned to.
accomplish [ə'kʌmpliʃ, ə'kɔm-] vt. 完成;实现;达到
abbreviated [ə'bri:vi,eitid] adj. 小型的;简短的;服装超短的
implied [im'plaid] v. 意思是(包含) a. 储蓄的 adj. 含蓄的;暗指的
21.To generalize, a lambda function is a function that takes any number of arguments (including optional arguments) and returns the value of a single expression.
22.All the dominoes are in place; it's time to knock them down.
domino ['dɔminəu] n. 多米诺骨牌;面具;化装外衣
23.The next piece of the puzzle is the use of str around the doc string.
24.ljust pads the string with spaces to the given length.
pad [[pæd]] vt. 填补;走
25.If the given length is smaller than the length of the string, ljust will simply return the string unchanged. It never truncates the string.
truncate ['trʌŋkeit, trʌŋ'keit, 'trʌŋk-] vt. 把…截短;缩短;[物]使成平面