學習Python(第五版,上下冊,影印版)
出版時間:2013年12月
頁數(shù):1600
“我愿意將《學習Python》最先推薦給那些想要通過Python來學習編程的人。”
——Doug Hellmann,
Racemi公司資深軟件工程師
通過這本操作手冊,你將獲得針對核心Python語言的一次全面而又深入的介紹。基于作者Mark Lutz的暢銷培訓課程,該第五版修訂本將可以幫助你快速使用Python編寫高效和高質量的代碼。無論你是編程新手還是精通其他語言的有經(jīng)驗的開發(fā)人員,這本書都適合于你。
通過小測驗、練習和有效的講解,這本易于遵循、自學的教程可以讓你上手Python 2.7和Python 3.3——3.x和2.x產(chǎn)品線上的最新發(fā)布版本——以及目前其他常見的版本。你也將學到一些最近在Python代碼中越來越常見的高級語言特性。
· 探討Python主要的內置對象類型,比如數(shù)字、列表和字典
· 使用Python語句創(chuàng)建和處理對象并且學習Python的通用語法模型
· 使用函數(shù)以避免代碼冗余并且重用包代碼
· 使用模塊來組織語句、函數(shù)和其他工具到更大的組件中
· 深入研究類:Python的適合于結構化代碼的面向對象編程工具
· 使用Python的異常處理和開發(fā)工具來編寫大型程序
· 學習高級Python工具,包括修飾符、描述符、元類和Unicode處理
Mark Lutz是世界級的Python培訓講師。他是最早和最暢銷Python書籍的作者。從1992年起,他就是Python社區(qū)的先鋒。Mark擁有30年的軟件開發(fā)經(jīng)驗,他是O’Reilly出版社的《Python編程》(第四版)和《Python Pocket Reference》(第四版)的作者。
- Chapter 1: A Python Q&A Session
- Why Do People Use Python?
- Is Python a “Scripting Language”?
- OK, but What’s the Downside?
- Who Uses Python Today?
- What Can I Do with Python?
- How Is Python Developed and Supported?
- What Are Python’s Technical Strengths?
- How Does Python Stack Up to Language X?
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 2: How Python Runs Programs
- Introducing the Python Interpreter
- Program Execution
- Execution Model Variations
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 3: How You Run Programs
- The Interactive Prompt
- System Command Lines and Files
- Unix-Style Executable Scripts: #!
- Clicking File Icons
- Module Imports and Reloads
- Using exec to Run Module Files
- The IDLE User Interface
- Other IDEs
- Other Launch Options
- Which Option Should I Use?
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part I Exercises
- Types and Operations
- Chapter 4: Introducing Python Object Types
- The Python Conceptual Hierarchy
- Why Use Built-in Types?
- Python’s Core Data Types
- Numbers
- Strings
- Lists
- Dictionaries
- Tuples
- Files
- Other Core Types
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 5: Numeric Types
- Numeric Type Basics
- Numbers in Action
- Other Numeric Types
- Numeric Extensions
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 6: The Dynamic Typing Interlude
- The Case of the Missing Declaration Statements
- Shared References
- Dynamic Typing Is Everywhere
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 7: String Fundamentals
- This Chapter’s Scope
- String Basics
- String Literals
- Strings in Action
- String Methods
- String Formatting Expressions
- String Formatting Method Calls
- General Type Categories
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 8: Lists and Dictionaries
- Lists
- Lists in Action
- Dictionaries
- Dictionaries in Action
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 9: Tuples, Files, and Everything Else
- Tuples
- Files
- Core Types Review and Summary
- Built-in Type Gotchas
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part II Exercises
- Statements and Syntax
- Chapter 10: Introducing Python Statements
- The Python Conceptual Hierarchy Revisited
- Python’s Statements
- A Tale of Two ifs
- A Quick Example: Interactive Loops
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 11: Assignments, Expressions, and Prints
- Assignment Statements
- Expression Statements
- Print Operations
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 12: if Tests and Syntax Rules
- if Statements
- Python Syntax Revisited
- Truth Values and Boolean Tests
- The if/else Ternary Expression
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 13: while and for Loops
- while Loops
- break, continue, pass, and the Loop else
- for Loops
- Loop Coding Techniques
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 14: Iterations and Comprehensions
- Iterations: A First Look
- List Comprehensions: A First Detailed Look
- Other Iteration Contexts
- New Iterables in Python 3.X
- Other Iteration Topics
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 15: The Documentation Interlude
- Python Documentation Sources
- Common Coding Gotchas
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part III Exercises
- Functions and Generators
- Chapter 16: Function Basics
- Why Use Functions?
- Coding Functions
- A First Example: Definitions and Calls
- A Second Example: Intersecting Sequences
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 17: Scopes
- Python Scope Basics
- The global Statement
- Scopes and Nested Functions
- The nonlocal Statement in 3.X
- Why nonlocal? State Retention Options
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 18: Arguments
- Argument-Passing Basics
- Special Argument-Matching Modes
- The min Wakeup Call!
- Generalized Set Functions
- Emulating the Python 3.X print Function
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 19: Advanced Function Topics
- Function Design Concepts
- Recursive Functions
- Function Objects: Attributes and Annotations
- Anonymous Functions: lambda
- Functional Programming Tools
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 20: Comprehensions and Generations
- List Comprehensions and Functional Tools
- Generator Functions and Expressions
- Comprehension Syntax Summary
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 21: The Benchmarking Interlude
- Timing Iteration Alternatives
- Timing Iterations and Pythons with timeit
- Other Benchmarking Topics: pystones
- Function Gotchas
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part IV Exercises
- Modules and Packages
- Chapter 22: Modules: The Big Picture
- Why Use Modules?
- Python Program Architecture
- How Imports Work
- Byte Code Files: __pycache__ in Python 3.2+
- The Module Search Path
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 23: Module Coding Basics
- Module Creation
- Module Usage
- Module Namespaces
- Reloading Modules
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 24: Module Packages
- Package Import Basics
- Package Import Example
- Why Use Package Imports?
- Package Relative Imports
- Python 3.3 Namespace Packages
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 25: Advanced Module Topics
- Module Design Concepts
- Data Hiding in Modules
- Enabling Future Language Features: __future__
- Mixed Usage Modes: __name__ and __main__
- Example: Dual Mode Code
- Changing the Module Search Path
- The as Extension for import and from
- Example: Modules Are Objects
- Importing Modules by Name String
- Example: Transitive Module Reloads
- Module Gotchas
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part V Exercises
- Classes and OOP
- Chapter 26: OOP: The Big Picture
- Why Use Classes?
- OOP from 30,000 Feet
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 27: Class Coding Basics
- Classes Generate Multiple Instance Objects
- Classes Are Customized by Inheritance
- Classes Can Intercept Python Operators
- The World’s Simplest Python Class
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 28: A More Realistic Example
- Step 1: Making Instances
- Step 2: Adding Behavior Methods
- Step 3: Operator Overloading
- Step 4: Customizing Behavior by Subclassing
- Step 5: Customizing Constructors, Too
- Step 6: Using Introspection Tools
- Step 7 (Final): Storing Objects in a Database
- Future Directions
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 29: Class Coding Details
- The class Statement
- Methods
- Inheritance
- Namespaces: The Conclusion
- Documentation Strings Revisited
- Classes Versus Modules
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 30: Operator Overloading
- The Basics
- Indexing and Slicing: __getitem__ and __setitem__
- Index Iteration: __getitem__
- Iterable Objects: __iter__ and __next__
- Membership: __contains__, __iter__, and __getitem__
- Attribute Access: __getattr__ and __setattr__
- String Representation: __repr__ and __str__
- Right-Side and In-Place Uses: __radd__ and __iadd__
- Call Expressions: __call__
- Comparisons: __lt__, __gt__, and Others
- Boolean Tests: __bool__ and __len__
- Object Destruction: __del__
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 31: Designing with Classes
- Python and OOP
- OOP and Inheritance: “Is-a” Relationships
- OOP and Composition: “Has-a” Relationships
- OOP and Delegation: “Wrapper” Proxy Objects
- Pseudoprivate Class Attributes
- Methods Are Objects: Bound or Unbound
- Classes Are Objects: Generic Object Factories
- Multiple Inheritance: “Mix-in” Classes
- Other Design-Related Topics
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 32: Advanced Class Topics
- Extending Built-in Types
- The “New Style” Class Model
- New-Style Class Changes
- New-Style Class Extensions
- Static and Class Methods
- Decorators and Metaclasses: Part 1
- The super Built-in Function: For Better or Worse?
- Class Gotchas
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part VI Exercises
- Exceptions and Tools
- Chapter 33: Exception Basics
- Why Use Exceptions?
- Exceptions: The Short Story
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 34: Exception Coding Details
- The try/except/else Statement
- The try/finally Statement
- Unified try/except/finally
- The raise Statement
- The assert Statement
- with/as Context Managers
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 35: Exception Objects
- Exceptions: Back to the Future
- Why Exception Hierarchies?
- Built-in Exception Classes
- Custom Print Displays
- Custom Data and Behavior
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 36: Designing with Exceptions
- Nesting Exception Handlers
- Exception Idioms
- Exception Design Tips and Gotchas
- Core Language Summary
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Test Your Knowledge: Part VII Exercises
- Advanced Topics
- Chapter 37: Unicode and Byte Strings
- String Changes in 3.X
- String Basics
- Coding Basic Strings
- Coding Unicode Strings
- Using 3.X bytes Objects
- Using 3.X/2.6+ bytearray Objects
- Using Text and Binary Files
- Using Unicode Files
- Other String Tool Changes in 3.X
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 38: Managed Attributes
- Why Manage Attributes?
- Properties
- Descriptors
- __getattr__ and __getattribute__
- Example: Attribute Validations
- Chapter Summary
- Test Your Knowledge: Quiz
- Chapter 39: Decorators
- What’s a Decorator?
- The Basics
- Coding Function Decorators
- Coding Class Decorators
- Managing Functions and Classes Directly
- Example: “Private” and “Public” Attributes
- Example: Validating Function Arguments
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 40: Metaclasses
- To Metaclass or Not to Metaclass
- The Metaclass Model
- Declaring Metaclasses
- Coding Metaclasses
- Inheritance and Instance
- Metaclass Methods
- Example: Adding Methods to Classes
- Example: Applying Decorators to Methods
- Chapter Summary
- Test Your Knowledge: Quiz
- Test Your Knowledge: Answers
- Chapter 41: All Good Things
- The Python Paradox
- Where to Go From Here
- Encore: Print Your Own Completion Certificate!
- Appendixes
- Appendix Installation and Configuration
- Installing the Python Interpreter
- Configuring Python
- For More Help
- Appendix The Python 3.3 Windows Launcher
- The Unix Legacy
- The Windows Legacy
- Introducing the New Windows Launcher
- A Windows Launcher Tutorial
- Pitfalls of the New Windows Launcher
- Conclusions: A Net Win for Windows
- Appendix Python Changes and This Book
- Major 2.X/3.X Differences
- General Remarks: 3.X Changes
- Fifth Edition Python Changes: 2.7, 3.2, 3.3
- Fourth Edition Python Changes: 2.6, 3.0, 3.1
- Third Edition Python Changes: 2.3, 2.4, 2.5
- Earlier and Later Python Changes
- Appendix Solutions to End-of-Part Exercises
- Part I, Getting Started
- Part II, Types and Operations
- Part III, Statements and Syntax
- Part IV, Functions and Generators
- Part V, Modules and Packages
- Part VI, Classes and OOP
- Part VII, Exceptions and Tools
書名:學習Python(第五版,上下冊,影印版)
國內出版社:東南大學出版社
出版時間:2013年12月
頁數(shù):1600
書號:978-7-5641-4597-2
原版書書名:Learning Python, 5th Edition
原版書出版商:O'Reilly Media
Mark Lutz
作為全球Python培訓界的領軍人物。Mark Lutz是Python最暢銷書籍的作者,也是Python社區(qū)的先驅。
Mark 是O’Reilly出版的《Programming Python》和《Python Pocket Reference》的作者,這兩本書于2009年都已經(jīng)出版了第3版。Mark自1992年開始接觸Python,1995年開始撰寫有關Python的書籍,從1997年開始教授Python課程。截止到2009年,他已經(jīng)開辦了225個Python短期培訓課程,教授了大約3500名學習者,銷售了大約25萬冊有關Python的書籍。許多書被翻譯成十多種語言。
此外,Mark擁有威斯康星大學計算機科學學士和碩士學位,在過去的25年中,他主要從事編譯器、編程工具、腳本程序以及各種客戶端/服務器系統(tǒng)方面的工作。你也可以通過訪問http://www.rmi.net/~lutz與他取得聯(lián)系。
"The animal on the cover of Learning Python, Fifth Edition, is a wood rat (Neotoma""Muridae). The wood rat lives in a wide range of conditions (mostly rocky, scrub, and desert areas) over much of North and Central America, generally at some distance from humans. Wood rats are good climbers, nesting in trees or bushes up to six meters off the ground; some species burrow underground or in rock crevices or inhabit other species’ abandoned holes."
"These grayish-beige, medium-size rodents are the original pack rats: they carry anything and everything into their homes, whether or not it’s needed, and are especially attracted to shiny objects such as tin cans, glass, and silverware."
"The cover image is a 19th-century engraving from Cuvier’s Animals. The cover font is Adobe ITC Garamond. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont’s TheSansMonoCondensed.