简介
Portable, powerful, and a breeze to use, Python is the popular open source object-oriented programming language used for both standalone programs and scripting applications. Python is considered easy to learn, but there's no quicker way to mastery of the language than learning from an expert teacher. This edition of Learning Pythonputs you in the hands of two expert teachers, Mark Lutz and David Ascher, whose friendly, well-structured prose has guided many a programmer to proficiency with the language.
Learning Python, Second Edition, offers programmers a comprehensive learning tool for Python and object-oriented programming. Thoroughly updated for the numerous language and class presentation changes that have taken place since the release of the first edition in 1999, this guide introduces the basic elements of the latest release of Python 2.3 and covers new features, such as list comprehensions, nested scopes, and iterators/generators.
Beyond language features, this edition of Learning Pythonalso includes new context for less-experienced programmers, including fresh overviews of object-oriented programming and dynamic typing, new discussions of program launch and configuration options, new coverage of documentation sources, and more. There are also new use cases throughout to make the application of language features more concrete.
The first part of Learning Pythongives programmers all the information they'll need to understand and construct programs in the Python language, including types, operators, statements, classes, functions, modules and exceptions. The authors then present more advanced material, showing how Python performs common tasks by offering real applications and the libraries available for those applications. Each chapter ends with a series of exercises that will test your Python skills and measure your understanding.
Learning Python, Second Edition is a self-paced book that allows readers to focus on the core Python language in depth. As you work through the book, you'll gain a deep and complete understanding of the Python language that will help you to understand the larger application-level examples that you'll encounter on your own. If you're interested in learning Python--and want to do so quickly and efficiently--then Learning Python, Second Edition is your best choice.
目录
Preface p. xv
Getting Started
A Python Q&A Session p. 3
Why Do People Use Python? p. 3
Is Python a Scripting Language? p. 5
Okay, But What's the Downside? p. 6
Who Uses Python Today? p. 7
What Can I Do with Python? p. 8
What Are Python's Technical Strengths? p. 11
How Does Python Stack Up to Language X? p. 14
How Python Runs Programs p. 16
Introducing the Python Interpreter p. 16
Program Execution p. 17
Execution Model Variations p. 21
How You Run Programs p. 25
Interactive Coding p. 25
System Command Lines and Files p. 28
Clicking Windows File Icons p. 32
Module Imports and Reloads p. 36
The IDLE User Interface p. 40
Other IDEs p. 44
Embedding Calls p. 46
Frozen Binary Executables p. 47
Text Editor Launch Options p. 47
Other Launch Options p. 47
Future Possibilities? p. 47
Which Option Should I Use? p. 48
Part I Exercises p. 48
Types and Operations
Numbers p. 53
Python Program Structure p. 53
Why Use Built-in Types? p. 53
Numbers p. 55
Python Expression Operators p. 57
Numbers in Action p. 60
The Dynamic Typing Interlude p. 68
Strings p. 74
String Literals p. 75
Strings in Action p. 81
String Formatting p. 87
String Methods p. 90
General Type Categories p. 95
Lists and Dictionaries p. 97
Lists p. 97
Lists in Action p. 99
Dictionaries p. 103
Dictionaries in Action p. 105
Tuples, Files, and Everything Else p. 112
Tuples p. 112
Files p. 115
Type Categories Revisited p. 117
Object Generality p. 118
References Versus Copies p. 118
Comparisons, Equality, and Truth p. 121
Python's Type Hierarchies p. 123
Other Types in Python p. 125
Built-in Type Gotchas p. 125
Part II Exercises p. 127
Statements and Syntax
Assignment, Expressions, and Print p. 133
Assignment Statements p. 134
Expression Statements p. 140
Print Statements p. 142
if Tests p. 146
if Statements p. 146
Python Syntax Rules p. 149
Truth Tests p. 152
while and for Loops p. 155
while Loops p. 155
break, continue, pass, and the Loop else p. 156
for Loops p. 160
Loop Variations p. 164
Documenting Python Code p. 171
The Python Documentation Interlude p. 171
Common Coding Gotchas p. 182
Part III Exercises p. 184
Functions
Function Basics p. 189
Why Use Functions? p. 189
Coding Functions p. 190
A First Example: Definitions and Calls p. 193
A Second Example: Intersecting Sequences p. 194
Scopes and Arguments p. 197
Scope Rules p. 197
The global Statement p. 202
Scopes and Nested Functions p. 203
Passing Arguments p. 207
Special Argument Matching Modes p. 210
Advanced Function Topics p. 219
Anonymous Functions: lambda p. 219
Applying Functions to Arguments p. 224
Mapping Functions Over Sequences p. 227
Functional Programming Tools p. 228
List Comprehensions p. 229
Generators and Iterators p. 233
Function Design Concepts p. 236
Function Gotchas p. 239
Part IV Exercises p. 242
Modules
Modules: The Big Picture p. 247
Why Use Modules? p. 247
Python Program Architecture p. 248
How Imports Work p. 251
Module Coding Basics p. 257
Module Creation p. 257
Module Usage p. 258
Module Namespaces p. 261
Reloading Modules p. 266
Module Packages p. 270
Package Import Basics p. 270
Package Import Example p. 273
Why Use Package Imports? p. 275
A Tale of Three Systems p. 275
Advanced Module Topics p. 279
Data Hiding in Modules p. 279
Enabling Future Language Features p. 280
Mixed Usage Modes: __name__ and __main__ p. 280
Changing the Module Search Path p. 281
The import as Extension p. 282
Module Design Concepts p. 282
Module Gotchas p. 285
Part V Exercises p. 292
Classes and OOP
OOP: The Big Picture p. 297
Why Use Classes? p. 297
OOP from 30,000 Feet p. 299
Class Coding Basics p. 307
Classes Generate Multiple Instance Objects p. 307
Classes Are Customized by Inheritance p. 310
Classes Can Intercept Python Operators p. 314
Class Coding Details p. 317
The Class Statement p. 317
Methods p. 320
Inheritance p. 322
Operator Overloading p. 327
Namespaces: The Whole Story p. 337
Designing with Classes p. 343
Python and OOP p. 343
Classes as Records p. 344
OOP and Inheritance: "is-a" Relationships p. 346
OOP and Composition: "has-a" Relationships p. 348
OOP and Delegation p. 352
Multiple Inheritance p. 353
Classes Are Objects: Generic Object Factories p. 356
Methods Are Objects: Bound or Unbound p. 358
Documentation Strings Revisited p. 360
Classes Versus Modules p. 362
Advanced Class Topics p. 363
Extending Built-in Types p. 363
Pseudo-Private Class Attributes p. 366
"New Style" Classes in Python 2.2 p. 369
Class Gotchas p. 376
Part VI Exercises p. 384
Exceptions and Tools
Exception Basics p. 393
Why Use Exceptions? p. 393
Exception Handling: The Short Story p. 395
The try/except/else Statement p. 399
The try/finally Statement p. 404
The raise Statement p. 405
The assert Statement p. 408
Exception Objects p. 410
String-Based Exceptions p. 410
Class-Based Exceptions p. 411
General raise Statement Forms p. 418
Designing with Exceptions p. 420
Nesting Exception Handlers p. 420
Exception Idioms p. 423
Exception Design Tips p. 426
Exception Gotchas p. 430
Core Language Summary p. 432
Part VII Exercises p. 436
The Outer Layers
Common Tasks in Python p. 439
Conversions, Numbers, and Comparisons p. 443
Manipulating Strings p. 447
Data Structure Manipulations p. 452
Manipulating Files and Directories p. 458
Internet-Related Modules p. 473
Executing Programs p. 477
Debugging, Testing, Timing, Profiling p. 480
Exercises p. 483
Frameworks p. 485
An Automated Complaint System p. 486
Interfacing with COM: Cheap Public Relations p. 492
A Tkinter-Based GUI Editor for Managing Form Data p. 496
Jython: The Felicitous Union of Python and Java p. 504
Exercises p. 511
Python Resources p. 513
Layers of Community p. 513
The Process p. 517
Services and Products p. 518
The Legal Framework: The Python Software Foundation p. 518
Software p. 518
Popular Third-Party Software p. 520
Web Application Frameworks p. 529
Tools for Python Developers p. 531
Appendixes
Installation and Configuration p. 535
Solutions to Exercises p. 541
Index p. 577
Getting Started
A Python Q&A Session p. 3
Why Do People Use Python? p. 3
Is Python a Scripting Language? p. 5
Okay, But What's the Downside? p. 6
Who Uses Python Today? p. 7
What Can I Do with Python? p. 8
What Are Python's Technical Strengths? p. 11
How Does Python Stack Up to Language X? p. 14
How Python Runs Programs p. 16
Introducing the Python Interpreter p. 16
Program Execution p. 17
Execution Model Variations p. 21
How You Run Programs p. 25
Interactive Coding p. 25
System Command Lines and Files p. 28
Clicking Windows File Icons p. 32
Module Imports and Reloads p. 36
The IDLE User Interface p. 40
Other IDEs p. 44
Embedding Calls p. 46
Frozen Binary Executables p. 47
Text Editor Launch Options p. 47
Other Launch Options p. 47
Future Possibilities? p. 47
Which Option Should I Use? p. 48
Part I Exercises p. 48
Types and Operations
Numbers p. 53
Python Program Structure p. 53
Why Use Built-in Types? p. 53
Numbers p. 55
Python Expression Operators p. 57
Numbers in Action p. 60
The Dynamic Typing Interlude p. 68
Strings p. 74
String Literals p. 75
Strings in Action p. 81
String Formatting p. 87
String Methods p. 90
General Type Categories p. 95
Lists and Dictionaries p. 97
Lists p. 97
Lists in Action p. 99
Dictionaries p. 103
Dictionaries in Action p. 105
Tuples, Files, and Everything Else p. 112
Tuples p. 112
Files p. 115
Type Categories Revisited p. 117
Object Generality p. 118
References Versus Copies p. 118
Comparisons, Equality, and Truth p. 121
Python's Type Hierarchies p. 123
Other Types in Python p. 125
Built-in Type Gotchas p. 125
Part II Exercises p. 127
Statements and Syntax
Assignment, Expressions, and Print p. 133
Assignment Statements p. 134
Expression Statements p. 140
Print Statements p. 142
if Tests p. 146
if Statements p. 146
Python Syntax Rules p. 149
Truth Tests p. 152
while and for Loops p. 155
while Loops p. 155
break, continue, pass, and the Loop else p. 156
for Loops p. 160
Loop Variations p. 164
Documenting Python Code p. 171
The Python Documentation Interlude p. 171
Common Coding Gotchas p. 182
Part III Exercises p. 184
Functions
Function Basics p. 189
Why Use Functions? p. 189
Coding Functions p. 190
A First Example: Definitions and Calls p. 193
A Second Example: Intersecting Sequences p. 194
Scopes and Arguments p. 197
Scope Rules p. 197
The global Statement p. 202
Scopes and Nested Functions p. 203
Passing Arguments p. 207
Special Argument Matching Modes p. 210
Advanced Function Topics p. 219
Anonymous Functions: lambda p. 219
Applying Functions to Arguments p. 224
Mapping Functions Over Sequences p. 227
Functional Programming Tools p. 228
List Comprehensions p. 229
Generators and Iterators p. 233
Function Design Concepts p. 236
Function Gotchas p. 239
Part IV Exercises p. 242
Modules
Modules: The Big Picture p. 247
Why Use Modules? p. 247
Python Program Architecture p. 248
How Imports Work p. 251
Module Coding Basics p. 257
Module Creation p. 257
Module Usage p. 258
Module Namespaces p. 261
Reloading Modules p. 266
Module Packages p. 270
Package Import Basics p. 270
Package Import Example p. 273
Why Use Package Imports? p. 275
A Tale of Three Systems p. 275
Advanced Module Topics p. 279
Data Hiding in Modules p. 279
Enabling Future Language Features p. 280
Mixed Usage Modes: __name__ and __main__ p. 280
Changing the Module Search Path p. 281
The import as Extension p. 282
Module Design Concepts p. 282
Module Gotchas p. 285
Part V Exercises p. 292
Classes and OOP
OOP: The Big Picture p. 297
Why Use Classes? p. 297
OOP from 30,000 Feet p. 299
Class Coding Basics p. 307
Classes Generate Multiple Instance Objects p. 307
Classes Are Customized by Inheritance p. 310
Classes Can Intercept Python Operators p. 314
Class Coding Details p. 317
The Class Statement p. 317
Methods p. 320
Inheritance p. 322
Operator Overloading p. 327
Namespaces: The Whole Story p. 337
Designing with Classes p. 343
Python and OOP p. 343
Classes as Records p. 344
OOP and Inheritance: "is-a" Relationships p. 346
OOP and Composition: "has-a" Relationships p. 348
OOP and Delegation p. 352
Multiple Inheritance p. 353
Classes Are Objects: Generic Object Factories p. 356
Methods Are Objects: Bound or Unbound p. 358
Documentation Strings Revisited p. 360
Classes Versus Modules p. 362
Advanced Class Topics p. 363
Extending Built-in Types p. 363
Pseudo-Private Class Attributes p. 366
"New Style" Classes in Python 2.2 p. 369
Class Gotchas p. 376
Part VI Exercises p. 384
Exceptions and Tools
Exception Basics p. 393
Why Use Exceptions? p. 393
Exception Handling: The Short Story p. 395
The try/except/else Statement p. 399
The try/finally Statement p. 404
The raise Statement p. 405
The assert Statement p. 408
Exception Objects p. 410
String-Based Exceptions p. 410
Class-Based Exceptions p. 411
General raise Statement Forms p. 418
Designing with Exceptions p. 420
Nesting Exception Handlers p. 420
Exception Idioms p. 423
Exception Design Tips p. 426
Exception Gotchas p. 430
Core Language Summary p. 432
Part VII Exercises p. 436
The Outer Layers
Common Tasks in Python p. 439
Conversions, Numbers, and Comparisons p. 443
Manipulating Strings p. 447
Data Structure Manipulations p. 452
Manipulating Files and Directories p. 458
Internet-Related Modules p. 473
Executing Programs p. 477
Debugging, Testing, Timing, Profiling p. 480
Exercises p. 483
Frameworks p. 485
An Automated Complaint System p. 486
Interfacing with COM: Cheap Public Relations p. 492
A Tkinter-Based GUI Editor for Managing Form Data p. 496
Jython: The Felicitous Union of Python and Java p. 504
Exercises p. 511
Python Resources p. 513
Layers of Community p. 513
The Process p. 517
Services and Products p. 518
The Legal Framework: The Python Software Foundation p. 518
Software p. 518
Popular Third-Party Software p. 520
Web Application Frameworks p. 529
Tools for Python Developers p. 531
Appendixes
Installation and Configuration p. 535
Solutions to Exercises p. 541
Index p. 577
- 名称
- 类型
- 大小
光盘服务联系方式: 020-38250260 客服QQ:4006604884
云图客服:
用户发送的提问,这种方式就需要有位在线客服来回答用户的问题,这种 就属于对话式的,问题是这种提问是否需要用户登录才能提问
Video Player
×
Audio Player
×
pdf Player
×