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

English-012 DiveIntoPython

阅读更多
English-012 DiveIntoPython

1.You're already intimately familiar with repr and you don't even know it.
intimately  adv. 亲切地;熟悉地;私下地   intimate ['intimət]  adj. 亲密的;私人的;精通的;[婉]有性关系的

2.gotcha ['ɡɔtʃə]   [发音拼写] =(I have) got you [常用作插入语]

3.tagDataMap is a class attribute: literally, an attribute of the class. It is available before creating any instances of the class.
literally ['litərəli]   adv. 逐字地;照字面地

4.If the name of a Python function, class method, or attribute starts with (but doesn't end with) two underscores, it's private; everything else is public. Python has no concept of protected class methods (accessible only in their own class and descendant classes). Class methods are either private (accessible only in their own class) or public (accessible from anywhere).
underscore  vt. 强调;划线于…下 n. 底线,下划线
either or   二者择一的;要么…要么…

5.If you try to call a private method, Python will raise a slightly misleading exception, saying that the method does not exist.
slight [slait]  adj. 轻微的,少量的;脆弱的;细长的;不重要
misleading [,mis'li:diŋ]  adj. 令人误解的;引入歧途的

6.internally, the names of private methods and attributes are mangled and unmangled on the fly to make them seem inaccessible by their given names.
mangle ['mæŋɡl]  vt. 乱砍;轧布;损坏

7.but like many other things in Python, their privateness is ultimately a matter of convention, not force.
ultimately adv. 最后;根本;基本上
ultimate ['ʌltimət]   adj. 最终的;根本的;极限的

8.That's it for the hard-core object trickery. You'll see a real-world application of special class methods in Chapter 12, which uses getattr to create a proxy to a remote web service.
trickery ['trikəri]  n. 欺骗;奸计;诡计
real-world  adj. 现实生活的;工作的

9.In this chapter, you will dive into exceptions, file objects, for loops, and the os and sys modules. If you've used exceptions in another programming language, you can skim the first section to get a sense of Python's syntax. Be sure to tune in again for file handling.
skim [skim]  vi. 掠过;浏览
section ['sekʃən]  n. 章节;地区;截面;部门
tune [tju:n, tu:n]  vt. 调整;为…调音;使一致   tune in    收听;调谐;使…协调

10.An error occurred, the exception was printed (depending on your IDE, perhaps in an intentionally jarring shade of red).
jarring ['dʒɑ:riŋ]  adj. 刺耳的;不和谐的;辗轧

11.When the exception was raised, there was no code to explicitly notice it and deal with it, so it bubbled its way back to the default behavior built in to Python, which is to spit out some debugging information and give up. In the IDE, that's no big deal, but if that happened while your actual Python program was running, the entire program would come to a screeching halt.
bubble ['bʌbl]  vt. 使冒泡;滔滔不绝地说   vi. 沸腾,冒泡;发出气泡声
spit [spit]  vt. 吐,吐出;发出;发射    spit out 吐出
screeching ['skri:tʃiŋ]  n. 发动机啸声;尖叫
halt [hɔ:lt]  vi. 停止;踌躇,犹豫;立定 n. 停止;立定;休息

12.Sometimes an exception is really because you have a bug in your code (like accessing a variable that doesn't exist), but many times, an exception is something you can anticipate.
anticipate [æn'tisipeit]  vt. 预期,期望;占先,抢先;提前使用

13.If you're connecting to a database, it might be unavailable, or you might not have the correct security credentials to access it.
credential [kri'denʃəl] n. 国书,凭据,印信

14.When the open method raises an IOError exception, you're ready for it. The except IOError: line catches the exception and executes your own block of code, which in this case just prints a more pleasant error message.
pleasant ['plezənt]   adj. 令人愉快的,舒适的;讨人喜欢的,和蔼可亲的

15.I'm sure you've experienced this, and you know it's not fun.

16.The next example demonstrates how to use an exception to support platform-specific functionality. This code comes from the getpass module, a wrapper module for getting a password from the user. Getting a password is accomplished differently on UNIX, Windows, and Mac OS platforms, but this code encapsulates all of those differences.
demonstrate ['demənstreit]  vt. 证明;论证;展示
accomplished [ə'kʌmpliʃt]  adj. 熟练的,有技巧的;完成的;有修养的;有学问的
encapsulate [in'kæpsəleit]  vt. 压缩;将…装入胶囊;将…封进内部

17.Open files consume system resources, and depending on the file mode, other programs may not be able to access them. It's important to close files as soon as you're finished with them.
consume [kən'sju:m]  vt. 消耗,消费;使…著迷;挥霍

18.Just because a file is closed doesn't mean that the file object ceases to exist.
cease [si:s]  vi. 停止;终了 vt. 停止;结束

19.file is a synonym for open. This one-liner opens the file, reads its contents, and prints them.
synonym ['sinənim]  n. 同义词

20.It's amazing how often you use for loops in other languages when all you really want is a join or a list comprehension.

21.Don't ever do this. This is Visual Basic-style thinking. Break out of it. Just iterate through the list, as shown in the previous example.
ever ['evə]  adv. 曾经;究竟;永远

22.The sys module contains system-level information, such as the version of Python you're running (sys.version or sys.version_info), and system-level options such as the maximum allowed recursion depth (sys.getrecursionlimit() and sys.setrecursionlimit()).
maximum ['mæksiməm]  n. 极大,最大限度;最大量
recursion [ri'kə:ʃən]  循环,递归

23.You'll plow through this line later, after you dive into the os module.
plow [plau]  vi. 犁;耕地;破浪前进;开路

24.Iterating through the list with f, you use os.path.normcase(f) to normalize the case according to operating system defaults. normcase is a useful little function that compensates for case-insensitive operating systems that think that mahadeva.mp3 and mahadeva.MP3 are the same file.
normalize ['nɔ:məlaiz]   vt. 使规格化,使标准化;使正常化
compensate ['kɔmpenseit]  vi. 补偿,赔偿;抵消
case-insensitive: 区分大小写;大小写不敏感;区分大小

25.The glob module, on the other hand, takes a wildcard and returns the full path of all files and directories matching the wildcard. Here the wildcard is a directory path plus "*.mp3", which will match all .mp3 files. Note that each element of the returned list already includes the full path of the file.
wildcard  n. [计]通配符

26.Now consider this scenario: you have a music directory, with several subdirectories within it, with .mp3 files within each subdirectory. You can get a list of all of those with a single call to glob, by using two wildcards at once. One wildcard is the "*.mp3" (to match .mp3 files), and one wildcard is within the directory path itself, to match any subdirectory within c:\music.
scenario [si'nɑ:riəu, -'næ-, -'nεə-]  n. 情节;剧本;方案

27.The nested function getFileInfoClass can be called only from the function in which it is defined, listDirectory. As with any other function, you don't need an interface declaration or anything fancy; just define the function and code it.
fancy ['fænsi]   n.幻想;爱好

28.which classes are defined that could potentially handle those files.
potential [pəu'tenʃəl]  adj. 可能的;潜在的

29. It inspects the directory for the files to process, and then introspects its own module to see what special handler classes (like MP3FileInfo) are defined.
inspect [in'spekt]  vt. 检查;视察;检阅

30.listDirectory will handle them all, without modification, by handing off the real work to the appropriate classes and collating the results.
collate [kɔ'leit]  vt. 核对,校对;校勘

分享到:
评论

相关推荐

    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