`
sillycat
  • 浏览: 2543254 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

English-011 DiveIntoPython

阅读更多
English-011 DiveIntoPython

1.As usual, don't worry about the stuff you don't understand; that's what the rest of the chapter is for.
stuff [stʌf] n. 材料;东西;填充物;素材资料

2.Python has two ways of importing modules. Both are useful, and you should know when to use each. One way, import module, you've already seen in Section 2.4. The other way accomplishes the same thing, but it has subtle and important differences.
subtle ['sʌtl]  adj. 微妙的;敏感的;狡猾的;精细的;稀薄的

3.If you want to selectively import some attributes and methods but not others, use from module import.

4.If the module contains attributes or functions with the same name as ones in your module, you must use import module to avoid name conflicts.
conflict [kən'flikt, 'kɔnflikt]   n. 冲突,矛盾;争执;斗争

5.ok,  I'll do it with you, some amendment according to your sentence
amendment [ə'mendmənt] n. 修正案;改正;改善

6.Python is fully object-oriented: you can define your own classes, inherit from your own or built-in classes, and instantiate the classes you've defined.
inherit [in'herit]  vt. 继承;遗传而得
instantiate [in'stænʃieit] vt. 例示,举例说明

7.The name of this class is Loaf, and it doesn't inherit from any other class. Class names are usually capitalized, EachWordLikeThis, but this is only a convention, not a requirement.
capitalized  大写的  capitalize ['kæpitəlaiz]  vt. 使资本化;以大写字母写;估计…的价值
convention [kən'venʃən]  n. 大会;协定;惯例;习俗;约定

8.This class doesn't define any methods or attributes, but syntactically, there needs to be something in the definition, so you use pass. This is a Python reserved word that just means “move along, nothing to see here”. It's a statement that does nothing, and it's a good placeholder when you're stubbing out functions or classes.
syntactically   adv. 依照句法地;在语句构成上   syntactic [sin'tæktik] adj. 句法的;语法的;依据造句法的
reserved [ri'zə:vd]  v. 保留
stub [stʌb]  vt. 踩熄;连根拔除  stub out 踩熄

9.In Python, the ancestor of a class is simply listed in parentheses immediately after the class name. So the FileInfo class is inherited from the UserDict class.
ancestor ['ænsestə]  n. 始祖,祖先;被继承人

10. It would be tempting but incorrect to call this the constructor of the class.
tempting ['temptiŋ]  adj. 诱惑人的;吸引人的

11.I am aware that this is confusing at first; it's not really inconsistent, but it may appear inconsistent because it relies on a distinction (between bound and unbound methods) that you don't know about yet.
aware [ə'wεə] adj. 知道的;意识到的;有…方面知识的;懂世故的
confusing  adj. 令人困惑的;混淆的;混乱的
inconsistent [,inkən'sistənt] adj. 不一致的;前后矛盾的
rely [ri'lai]  vi. 信赖;依靠
bound [baund] n. 跳跃;范围

12.Instantiating classes in Python is straightforward. To instantiate a class, simply call the class as if it were a function, passing the arguments that the __init__ method defines. The return value will be the newly created object.
straightforward [,streit'fɔ:wəd]  adj. 简单的;坦率的;明确的;径直的

13.In general, there is no need to explicitly free instances, because they are freed automatically when the variables assigned to them go out of scope. Memory leaks are rare in Python.
rare [rεə] adj. 半熟的;稀有的;稀薄的

14.As a former philosophy major, it disturbs me to think that things disappear when no one is looking at them, but that's exactly what happens in Python. In general, you can simply forget about memory management and let Python clean up after you.
former ['fɔ:mə]  adj. 从前的,前者的;前任的
philosophy [fi'lɔsəfi, fə-]  n. 哲学;哲理;人生观
major ['meidʒə] n. 成年人;主修科目;陆军少校

15.This is the __init__ method that you overrode in the FileInfo class. Note that the argument list in this ancestor class is different than the descendant. That's okay; each subclass can have its own set of arguments, as long as it calls the ancestor with the correct arguments. Here the ancestor class has a way to define initial values (by passing a dictionary in the dict argument) which the FileInfo does not use.
ancestor ['ænsestə]  n. 始祖,祖先;被继承人
descendant [di'sendənt]  adj. 下降的;祖传的 n. 子孙;后裔

16.By convention, all data attributes are initialized to reasonable values in the __init__ method. However, this is not required, since data attributes, like local variables, spring into existence when they are first assigned a value.
by convention    按照惯例
spring into existence

17.The update method is a dictionary duplicator: it copies all the keys and values from one dictionary to another. This does not clear the target dictionary first; if the target dictionary already has some keys, the ones from the source dictionary will be overwritten, but others will be left untouched. Think of update as a merge function, not a copy function.
duplicator ['dju:plikeitə]  n. 复制者;复印机
untouched [,ʌn'tʌtʃt]  adj. 未受影响的;未改变的;未触动过的;不受感动的
merge [mə:dʒ]  vt. 合并;吞没;使合并

18.The third difference is subtle but important. Because of the way UserDict works internally, it requires you to manually call its __init__ method to properly initialize its internal data structures. dict does not work like this; it is not a wrapper, and it requires no explicit initialization.
subtle ['sʌtl] adj. 微妙的;敏感的;狡猾的;精细的;稀薄的
wrapper ['ræpə]  n. 包装材料;包装纸;书皮                     Wrapper Class: 包装类;包装函式类别;包裹类;封装/包裹类

19.This looks like regular dictionary syntax, except of course that f is really a class that's trying very hard to masquerade as a dictionary, and __setitem__ is an essential part of that masquerade. This line of code actually calls f.__setitem__("genre", 32) under the covers.
masquerade [,mæskə'reid]  vi. 化装;伪装 vt. 化装;乔装
essential [i'senʃəl]  adj. 必要的;基本的;本质的;精华的

20.fluent ['flu(:)ənt]   adj. 流畅的,流利的;液态的;畅流的

21.Technically speaking, the names of the arguments don't matter; only the number of arguments is important.
generally/technically {etc} speaking: 总的/从技术上{等}来说
technical ['teknikəl]  adj. 技术上的;工艺的,科技的;专门的

22.Here's the crux of the entire MP3FileInfo class: if you're assigning a value to the name key, you want to do something extra.
crux [krʌks]   n. 关键;难题;十字架形,坩埚

23.After doing this extra processing, you want to call the ancestor method. Remember that this is never done for you in Python; you must do it manually. Note that you're calling the immediate ancestor, FileInfo, even though it doesn't have a __setitem__ method. That's okay, because Python will walk up the ancestor tree until it finds a class with the method you're calling, so this line of code will eventually find and call the __setitem__ defined in UserDict.
extra ['ekstrə]  adv. 特别地,非常;另外
immediate [i'mi:diət]  adj. 直接的;立即的;最接近的
eventually [i'ventʃuəli]  adv. 最后,终于

24.Python has more special methods than just __getitem__ and __setitem__. Some of them let you emulate functionality that you may not even know about.
emulate ['emjuleit, 'emjulit]   vt. 仿真;模仿;尽力赶上;同…竞争
functionality [,fʌŋkʃə'næliti]  n. 泛函性,函数性;功能

分享到:
评论

相关推荐

    Test-Driven Development with Python [2017]

    Dive into the TDD workflow, including the unit test/code cycle and refactoring Use unit tests for classes and functions, and functional tests for user interactions within the browser Learn when and ...

    MQTT Essentials - A Lightweight IoT Protocol

    Dive deep into one of IoT's extremely lightweight machines to enable connectivity protocol with some real-world examples Learn to take advantage of the features included in MQTT for IoT and Machine-to...

    Large Scale Machine Learning with Python

    Dive into scalable machine learning and the three forms of scalability. Speed up algorithms that can be used on a desktop computer with tips on parallelization and memory allocation. Get to grips with...

    Python Data Analysis Cookbook

    In this book, you will dive deeper into recipes on spectral analysis, smoothing, and bootstrapping methods. Moving on, you will learn to rank stocks and check market efficiency, then work with metrics...

    Python Deep Learning

    Whether you want to dive deeper into Deep Learning, or want to investigate how to get more out of this powerful technology, you’ll find everything inside. What you will learn Get a practical deep ...

    LargeScaleMachineLearningwithPython.pdf

    Large Scale Machine Learning with Python [PDF + EPUB + CODE] Packt Publishing | August 4, 2016 | English | 439 pages Large Python machine learning projects involve new problems associated with ...

    Hands-On Machine Learning with Scikit-Learn and TensorFlow [EPUB]

    decision trees, random forests, and ensemble methods Use the TensorFlow library to build and train neural nets Dive into neural net architectures, including convolutional nets, recurrent nets, and ...

    Hands-On Machine Learning with Scikit-Learn and TensorFlow [Kindle Edition]

    Dive into neural net architectures, including convolutional nets, recurrent nets, and deep reinforcement learning Learn techniques for training and scaling deep neural nets Apply practical code ...

    Machine.Learning.in.Python

    The chapters on penalized linear regression and ensemble methods dive deep into each of the algorithms, and you can use the sample code in the book to develop your own data analysis solutions. ...

    Machine Learning in Python 无水印pdf 0分

    The chapters on penalized linear regression and ensemble methods dive deep into each of the algorithms, and you can use the sample code in the book to develop your own data analysis solutions....

    Python Machine Learning By Example [2017].azw3电子书下载

    Dive deep into the world of analytics to predict situations correctly Implement machine learning classification and regression algorithms from scratch in Python Be amazed to see the algorithms in ...

    Advanced Analytics with Spark: Patterns for Learning from Data at Scale

    You’ll start with an introduction to Spark and its ecosystem, and then dive into patterns that apply common techniques—including classification, clustering, collaborative filtering, and anomaly ...

    Building Recommendation Engines

    Dive into the various techniques of recommender systems such as collaborative, content-based, and cross-recommendations Create efficient decision-making systems that will ease your work Familiarize ...

    Raspberry Pi Zero Cookbook

    Deep dive into the components of the small yet powerful Raspberry Pi Zero Get into grips with integrating various hardware, programming, and networking concepts with the so-called “cheapest computer...

    Packt.Django.Project.Blueprints.2016

    Dive deep into Django forms and how they work internally About the Author Asad Jibran Ahmed is an experienced programmer who has worked mostly with Django-based web applications for the past 5 years. ...

    React and React Native [Kindle Edition]

    Dive deep into each platform, from routing in React to creating native mobile applications that can run offline Use Facebook's Relay, React and GraphQL technologies, to create a unified architecture ...

Global site tag (gtag.js) - Google Analytics