Dive Into Python-Chapter 17. Dynamic functions
... Chapter 17. Dynamic functions 17. 1. Diving in I want to talk about plural nouns. Also, functions that return other functions, advanced regular expressions, and ... including functions. rules contains actual functions; not names of functions, but actual functions. When they get assigned in the for loop, then matchesRule and applyRule are actual functions ... turn a noun into...
Ngày tải lên: 28/10/2013, 16:15
... Certified Open Source: Pythonline http://www.pythonline.com/ Dive Into <b>Python</b> http://diveintopython.org/ Dive Into <b>Python</b>. <b>Python</b> from ... sample output for a search for the word “python”. Example 12.2. Sample Usage of search.py C:\diveintopython\common\py> python search.py "python" <b>Python</b> Program...
Ngày tải lên: 17/10/2013, 19:15
Dive Into Python-Chapter 13. Unit Testing
... behavior you expect from your conversion functions, you're going to do something a little unexpected: you're going to write a test suite that puts these functions through their paces and makes ... goes off too far into developing code that won't play well with others.) 13.3. Introducing romantest.py This is the complete test suite for your Roman numeral conversion functio...
Ngày tải lên: 20/10/2013, 10:15
Dive Into Python-Chapter 14. Test-First Programming
... as specified in FromRomanBadInput. 4 At this stage, you want to define the API of each of your functions, but you don't want to code them yet, so you stub them out using the Python reserved ... to romantest.py and re-evaluate why you coded a test so useless that it passes with do-nothing functions. Run romantest1.py with the -v command-line option, which will give more verbose output
Ngày tải lên: 20/10/2013, 10:15
Dive Into Python-Chapter 15. Refactoring
... change. Suppose, for instance, that you wanted to expand the range of the Roman numeral conversion functions. Remember the rule that said that no character could be repeated more than three times? ... 'MCCCI'), (1485, 'MCDLXXXV'), (1509, 'MDIX'), (1607, 'MDCVII'), (175 4, 'MDCCLIV'), (1832, 'MDCCCXXXII'), (1993, 'MCMXCIII'...
Ngày tải lên: 24/10/2013, 09:15
Dive Into Python-Chapter 16. Functional Programming
... sys.argv[0] = /home/you/diveintopython/common/py/fullpath.py path = /home/you/diveintopython/common/py full path = /home/you/diveintopython/common/py [you@localhost diveintopython]$ python common/py/fullpath.py ... /home/you/diveintopython/common/py [you@localhost diveintopython]$ cd common/py [you@localhost py]$ python fullpath.py 3 sys.argv[0] = fullpath.py path = full path = /home/you/dive...
Ngày tải lên: 24/10/2013, 09:15
Dive Into Python-Chapter 18. Performance Tuning
... servers, check for application updates, scan for viruses, check whether a disk has been inserted into your CD drive in the last 100 nanoseconds, and so on. Before you start your timing tests, turn ... nothing to get terribly excited about: C:\samples\soundex\stage1>python soundex1b.py Woo W000 17. 1361133887 Pilgrim P426 21.8201693232 Flingjingwaller F452 32.7262294509 We saw in Section...
Ngày tải lên: 28/10/2013, 16:15
Dive Into Python-Chapter 1. Installing Python
... Chapter 1. Installing Python Welcome to Python. Let's dive in. In this chapter, you'll install the version of Python that's right for you. ... that scripts are running under the latest version of Python, and be sure to type python2.3 to get into the interactive shell. 1.6. Python on Debian GNU/Linux If you are lucky enough to be running ... calculator! Launch the Pyt...
Ngày tải lên: 07/11/2013, 10:15
... will look like this: server=mpilgrim;uid=sa;database=master;pwd=secret 2.2. Declaring Functions Python has functions like most other languages, but it does not have separate header files like ... Basic, functions (that return a value) start with function, and subroutines (that do not return a value) start with sub. There are no subroutines in Python. Everything is a function, all...
Ngày tải lên: 07/11/2013, 10:15
Dive Into Python-Chapter 3. Native Datatypes
... dictionaries, functions, and modules Concatenating values through string formatting Mapping lists into other lists using list comprehensions Splitting strings into lists and joining lists into ... all the string functions; each function took a string as its first argument. The functions were deemed important enough to put onto the strings themselves, which made sense for...
Ngày tải lên: 07/11/2013, 10:15