Learning Python

Learning Python

by Mark Lutz

Paperback(Fifth Edition)

$58.49 $64.99 Save 10% Current price is $58.49, Original price is $64.99. You Save 10%.
View All Available Formats & Editions
Choose Expedited Shipping at checkout for guaranteed delivery by Friday, November 16

Product Details

ISBN-13: 9781449355739
Publisher: O'Reilly Media, Incorporated
Publication date: 07/03/2013
Edition description: Fifth Edition
Pages: 1540
Sales rank: 46,520
Product dimensions: 7.00(w) x 9.20(h) x 2.80(d)

About the Author

Mark Lutz is a leading Python trainer, the author of Python’s earliest and best-selling texts, and a pioneering figure in the Python world.

Mark is the author of the three O’Reilly books: Learning Python , Programming Python , and Python Pocket Reference , all currently in fourth or fifth editions. He has been using and promoting Python since 1992, started writing Python books in 1995, and began teaching Python classes in 1997. As of Spring 2013, Mark has instructed 260 Python training sessions, taught roughly 4,000 students in live classes, and written Python books that have sold 400,000 units and been translated to at least a dozen languages.

Together, his two decades of Python efforts have helped to establish it as one of the most widely used programming languages in the world today. In addition, Mark has been in the software field for 30 years. He holds BS and MS degrees in computer science from the University of Wisconsin where he explored implementations of the Prolog language, and over his career has worked as a professional software developer on compilers, programming tools, scripting applications, and assorted client/server systems.

Mark maintains a training website ( http://learning-python.com ) and an additional book support site on the Web ( http://www.rmi.net/~lutz ).

Table of Contents

Part I.Getting Started
1.A Python Q&A Session3
Why Do People Use Python?3
Is Python a Scripting Language?5
Okay, But What's the Downside?6
Who Uses Python Today?7
What Can I Do with Python?8
What Are Python's Technical Strengths?11
How Does Python Stack Up to Language X?14
2.How Python Runs Programs16
Introducing the Python Interpreter16
Program Execution17
Execution Model Variations21
3.How You Run Programs25
Interactive Coding25
System Command Lines and Files28
Clicking Windows File Icons32
Module Imports and Reloads36
The IDLE User Interface40
Other IDEs44
Embedding Calls46
Frozen Binary Executables47
Text Editor Launch Options47
Other Launch Options47
Future Possibilities?47
Which Option Should I Use?48
Part I Exercises48
Part II.Types and Operations
Python Program Structure53
Why Use Built-in Types?53
Python Expression Operators57
Numbers in Action60
The Dynamic Typing Interlude68
String Literals75
Strings in Action81
String Formatting87
String Methods90
General Type Categories95
6.Lists and Dictionaries97
Lists in Action99
Dictionaries in Action105
7.Tuples, Files, and Everything Else112
Type Categories Revisited117
Object Generality118
References Versus Copies118
Comparisons, Equality, and Truth121
Python's Type Hierarchies123
Other Types in Python125
Built-in Type Gotchas125
Part II Exercises127
Part III.Statements and Syntax
8.Assignment, Expressions, and Print133
Assignment Statements134
Expression Statements140
Print Statements142
9.if Tests146
if Statements146
Python Syntax Rules149
Truth Tests152
10.while and for Loops155
while Loops155
break, continue, pass, and the Loop else156
for Loops160
Loop Variations164
11.Documenting Python Code171
The Python Documentation Interlude171
Common Coding Gotchas182
Part III Exercises184
Part IV.Functions
12.Function Basics189
Why Use Functions?189
Coding Functions190
A First Example: Definitions and Calls193
A Second Example: Intersecting Sequences194
13.Scopes and Arguments197
Scope Rules197
The global Statement202
Scopes and Nested Functions203
Passing Arguments207
Special Argument Matching Modes210
14.Advanced Function Topics219
Anonymous Functions: lambda219
Applying Functions to Arguments224
Mapping Functions Over Sequences227
Functional Programming Tools228
List Comprehensions229
Generators and Iterators233
Function Design Concepts236
Function Gotchas239
Part IV Exercises242
Part V.Modules
15.Modules: The Big Picture247
Why Use Modules?247
Python Program Architecture248
How Imports Work251
16.Module Coding Basics257
Module Creation257
Module Usage258
Module Namespaces261
Reloading Modules266
17.Module Packages270
Package Import Basics270
Package Import Example273
Why Use Package Imports?275
A Tale of Three Systems275
18.Advanced Module Topics279
Data Hiding in Modules279
Enabling Future Language Features280
Mixed Usage Modes: __name__ and __main__280
Changing the Module Search Path281
The import as Extension282
Module Design Concepts282
Module Gotchas285
Part V Exercises292
Part VI.Classes and OOP
19.OOP: The Big Picture297
Why Use Classes?297
OOP from 30,000 Feet299
20.Class Coding Basics307
Classes Generate Multiple Instance Objects307
Classes Are Customized by Inheritance310
Classes Can Intercept Python Operators314
21.Class Coding Details317
The Class Statement317
Operator Overloading327
Namespaces: The Whole Story337
22.Designing with Classes343
Python and OOP343
Classes as Records344
OOP and Inheritance: "is-a" Relationships346
OOP and Composition: "has-a" Relationships348
OOP and Delegation352
Multiple Inheritance353
Classes Are Objects: Generic Object Factories356
Methods Are Objects: Bound or Unbound358
Documentation Strings Revisited360
Classes Versus Modules362
23.Advanced Class Topics363
Extending Built-in Types363
Pseudo-Private Class Attributes366
"New Style" Classes in Python 2.2369
Class Gotchas376
Part VI Exercises384
Part VII.Exceptions and Tools
24.Exception Basics393
Why Use Exceptions?393
Exception Handling: The Short Story395
The try/except/else Statement399
The try/finally Statement404
The raise Statement405
The assert Statement408
25.Exception Objects410
String-Based Exceptions410
Class-Based Exceptions411
General raise Statement Forms418
26.Designing with Exceptions420
Nesting Exception Handlers420
Exception Idioms423
Exception Design Tips426
Exception Gotchas430
Core Language Summary432
Part VII Exercises436
Part VIII.The Outer Layers
27.Common Tasks in Python439
Conversions, Numbers, and Comparisons443
Manipulating Strings447
Data Structure Manipulations452
Manipulating Files and Directories458
Internet-Related Modules473
Executing Programs477
Debugging, Testing, Timing, Profiling480
An Automated Complaint System486
Interfacing with COM: Cheap Public Relations492
A Tkinter-Based GUI Editor for Managing Form Data496
Jython: The Felicitous Union of Python and Java504
29.Python Resources513
Layers of Community513
The Process517
Services and Products518
The Legal Framework: The Python Software Foundation518
Popular Third-Party Software520
Web Application Frameworks529
Tools for Python Developers531
Part IX.Appendixes
A.Installation and Configuration535
B.Solutions to Exercises541

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews

Learning Python 3.3 out of 5 based on 0 ratings. 21 reviews.
sldonb42 More than 1 year ago
If you go to the page for the 4th edition and press the link to download a sample, you WILL get a sample for the 2nd edition...covering Python 2.3, not 2.6 and 3.1. The same if you buy it without rooting around through the editions listed as ebooks. B&N will then tell you that they do not issue refunds for ebooks.
Guest More than 1 year ago
It gives a thorough description of how to use Python; which is indeed easy to learn if you already know another language. But when the authors say that not having to compile Python programs means that development time is speeded up, perhaps they are overstating. For most programmers who use compiled languages like C or C++, the biggest time is taken up in finding a method that solves a problem, coding it and subsequent debugging. These days, compilers on recent hardware are fast enough that link/compile times are simply not a bottleneck to development productivity. So it is a bit of a straw dummy that the authors put forth. However, they are absolutely spot on when comparing this to Perl or Tcl. Perl is powerful, but its code looks like assembler. Perl gurus tend to shrug when you point this out, usually saying they understand it, with the not-so-implicit suggestion that if you can't, it is your fault. But this leads to a real maintenance problem and a barrier to entry to others. The cleaner Python syntax can show coding intent far clearer. Plus, and more importantly, the object oriented nature of Python lets you scale up to much larger programs. This has always been a problem with scripting languages, all the way back to the various unix shell scripts and DOS bat files. Often, the most those ever gave you in terms of modular capabilities was the equivalent of subroutines. Which is strictly procedural and not OO. By the way, there is a small contradiction between the above claim that Python is more understandable than Perl and the claim that it has an advantage over C++ or Java because it is not as verbose as those. Typically, in increasing amount of source code, you have Perl -> Python -> (C++,Java). If you think that Python is more understandable than Perl, then by that same logic, we could conclude that C++ or Java is more understandable than Python. So if you are using Perl or Tcl and want something better, Python is a good choice. A good upgrade path. But if you are currently using C or C++, with maybe X for graphics, or Java, then I suggest you stay with those. All three languages, with their graphics, give you a far richer toolset. Python would be a retrograde choice.
Anonymous More than 1 year ago
The sample gives no understanding of how this book will be teaching the language and is just about the history of python, its uses and the authors view on 2.x vs 3.x. Hard to tell what this book will be like as it gets very mixed reviews.
Anonymous More than 1 year ago
Even the sample is very good.The very very good book for beginner.
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Never give up.
Anonymous More than 1 year ago
Excellent for beginner but still worthwhile for more advanced python programmer
Anonymous More than 1 year ago
Anonymous More than 1 year ago
This is an excellent book to teach yourself Python! I have the 4th edition. It focuses on Python 3.2 but explains the differences with Python 2.7 and earlier versions as those areas are encountered in the book. The book starts with the basics, which most will find very easy, and proceeds to the most advanced Python topics. Every chapter builds on what was taught in previous chapters. There are numerous WORKING examples throughout the book, and the author has a web site where you may down load all of the examples. I have Python 3.2 and 2.7 and have run most of the examples in both versions. This is an EXCELLENT book if you need, or just want to learn Python!
Anonymous More than 1 year ago
Its a freaking 4494 page sample totally get the free sample( this ' sample'includes all chaptets except the appendexs)very well written good for the begginnr and more experianced alike
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Anonymous More than 1 year ago