Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
7Activity
0 of .
Results for:
No results containing your search query
P. 1
2004 Dive Into Python Apress

2004 Dive Into Python Apress

Ratings: (0)|Views: 26|Likes:
Published by Gerhart67
Help to get you started in the python language
Help to get you started in the python language

More info:

Published by: Gerhart67 on Jun 21, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

06/25/2010

pdf

text

original

 
Table of Contents
Dive Into Python...............................................................................................................................................................1Chapter 1. Installing Python...........................................................................................................................................2
1.1. Which Python is right for you?......................................................................................................................21.2. Python on Windows.......................................................................................................................................21.3. Python on Mac OS X.....................................................................................................................................31.4. Python on Mac OS 9......................................................................................................................................51.5. Python on RedHat Linux...............................................................................................................................51.6. Python on DebianGNU/Linux......................................................................................................................61.7. Python Installation from Source....................................................................................................................61.8. The Interactive Shell......................................................................................................................................71.9. Summary........................................................................................................................................................8
Chapter 2. Your First Python Program.........................................................................................................................9
2.1. Diving in........................................................................................................................................................92.2. Declaring Functions.......................................................................................................................................92.3. Documenting Functions...............................................................................................................................102.4. Everything Is an Object...............................................................................................................................112.5. Indenting Code.............................................................................................................................................132.6. Testing Modules...........................................................................................................................................14
Chapter 3. Native Datatypes.........................................................................................................................................15
3.1. Introducing Dictionaries..............................................................................................................................153.2. Introducing Lists..........................................................................................................................................173.3. Introducing Tuples.......................................................................................................................................223.4. Declaring variables......................................................................................................................................233.5. Formatting Strings.......................................................................................................................................253.6. Mapping Lists..............................................................................................................................................263.7. Joining Lists and Splitting Strings...............................................................................................................283.8. Summary......................................................................................................................................................29
Chapter 4. ThePower Of Introspection.......................................................................................................................31
4.1. Diving In......................................................................................................................................................314.2. Using Optional and Named Arguments.......................................................................................................324.3. Usingtype,str,dir, and Other Built−In Functions......................................................................................334.4. Getting Object References Withgetattr.......................................................................................................364.5. Filtering Lists...............................................................................................................................................384.6. ThePeculiar Nature ofand andor...............................................................................................................394.7. Usinglambda Functions..............................................................................................................................414.8. Putting It All Together.................................................................................................................................434.9. Summary......................................................................................................................................................45
Chapter 5. Objects and Object−Orientation...............................................................................................................47
5.1. Diving In......................................................................................................................................................475.2. Importing Modules Usingfrom module import...........................................................................................495.3. Def ining Classes..........................................................................................................................................505.4. Instantiating Classes.....................................................................................................................................535.5. ExploringUserDict: A Wrapper Class........................................................................................................545.6. Special Class Methods.................................................................................................................................565.7. Advanced Special Class Methods................................................................................................................59
Dive Into Pythoni
 
Table of Contents
Chapter 5. Objects and Object−Orientation
5.8. Introducing Class Attributes........................................................................................................................605.9. Private Functions.........................................................................................................................................625.10. Summary....................................................................................................................................................63
Chapter 6. Exceptions and File Handling....................................................................................................................64
6.1. Handling Exceptions....................................................................................................................................646.2. Working with File Objects...........................................................................................................................666.3. Iterating withfor Loops...............................................................................................................................706.4. Usingsys.modules.......................................................................................................................................726.5. Working with Directories............................................................................................................................746.6. Putting It All Together.................................................................................................................................776.7. Summary......................................................................................................................................................78
Chapter 7. Regular Expressions...................................................................................................................................81
7.1. Diving In......................................................................................................................................................817.2. Case Study: Street Addresses.......................................................................................................................817.3. Case Study: Roman Numerals.....................................................................................................................837.4. Using the{n,m} Syntax...............................................................................................................................857.5. Verbose Regular Expressions......................................................................................................................887.6. Case study: Parsing PhoneNumbers...........................................................................................................897.7. Summary......................................................................................................................................................93
Chapter 8. HTML Processing.......................................................................................................................................94
8.1. Diving in......................................................................................................................................................948.2. Introducingsgmllib.py.................................................................................................................................988.3. Extracting data from HTML documents....................................................................................................1008.4. IntroducingBaseHTMLProcessor.py........................................................................................................1028.5. locals andglobals.......................................................................................................................................1048.6. Dictionary−based string formatting...........................................................................................................1078.7. Quoting attribute values.............................................................................................................................1088.8. Introducingdialect.py................................................................................................................................1098.9. Putting it all together..................................................................................................................................1118.10. Summary..................................................................................................................................................113
Chapter 9. XML Processing........................................................................................................................................115
9.1. Diving in....................................................................................................................................................1159.2. Packages.....................................................................................................................................................1219.3. Parsing XML..............................................................................................................................................1239.4. Unicode......................................................................................................................................................1259.5. Searching for elements...............................................................................................................................1299.6. Accessing element attributes......................................................................................................................1319.7. Segue..........................................................................................................................................................132
Chapter 10. Scripts and Streams................................................................................................................................133
10.1. Abstracting input sources.........................................................................................................................13310.2. Standard input, output, and error.............................................................................................................13610.3. Caching node lookups..............................................................................................................................14010.4. Finding direct children of a node.............................................................................................................14110.5. Creating separate handlers by node type.................................................................................................141
Dive Into Pythonii
 
Table ofContents
Chapter 10. Scripts and Streams
10.6. Handling command−line arguments........................................................................................................14310.7. Putting it all together................................................................................................................................14610.8. Summary..................................................................................................................................................148
Chapter 11. HTTP Web Services................................................................................................................................149
11.1. Diving in..................................................................................................................................................14911.2. How not to fetch data over HTTP............................................................................................................15111.3. Features of HTTP.....................................................................................................................................15211.4. Debugging HTTP web services...............................................................................................................15311.5. Setting theUser−Agent............................................................................................................................15511.6. HandlingLast−Modified andETag.........................................................................................................15611.7. Handling redirects....................................................................................................................................15911.8. Handling compressed data.......................................................................................................................16311.9. Putting it all together................................................................................................................................16511.10. Summary................................................................................................................................................167
Chapter 12. SOAP Web Services................................................................................................................................168
12.1. Diving In..................................................................................................................................................16812.2. Installing the SOAP Libraries..................................................................................................................16912.3. First Steps with SOAP.............................................................................................................................17112.4. Debugging SOAP Web Services.............................................................................................................17212.5. Introducing WSDL...................................................................................................................................17312.6. Introspecting SOAP Web Services with WSDL......................................................................................17412.7. Searching Google.....................................................................................................................................17612.8. Troubleshooting SOAP Web Services.....................................................................................................17912.9. Summary..................................................................................................................................................182
Chapter 13. Unit Testing.............................................................................................................................................183
13.1. Introduction to Roman numerals.............................................................................................................18313.2. Diving in..................................................................................................................................................18413.3. Introducingromantest.py.........................................................................................................................18413.4. Testing for success...................................................................................................................................18713.5. Testing for failure....................................................................................................................................18913.6. Testing for sanity.....................................................................................................................................190
Chapter 14. Test−First Programming........................................................................................................................193
14.1. roman.py, stage 1.....................................................................................................................................19314.2. roman.py, stage 2.....................................................................................................................................19614.3. roman.py, stage 3.....................................................................................................................................19914.4. roman.py, stage 4.....................................................................................................................................20214.5. roman.py, stage 5.....................................................................................................................................205
Chapter 15. Refactoring..............................................................................................................................................208
15.1. Handling bugs..........................................................................................................................................20815.2. Handling changing requirements.............................................................................................................21015.3. Refactoring...............................................................................................................................................21615.4. Postscript..................................................................................................................................................21915.5. Summary..................................................................................................................................................221
Dive Into Pythoniii

Activity (7)

You've already reviewed this. Edit your review.
1 hundred reads
oobin liked this
hesc5523 liked this
ksahara liked this
hazlewp2657 liked this
fred3112 liked this
whittirs liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->