This is a great little book. I have had three revisions of it and plan to get the next one when it is published. I keep it in my mini 10v running ubuntu linux (9.10) netbook's sleeve when I travel. Perfect little reference and easily worth the cost. Table of Contents 7 Introduction 13 Conventions 14 Using Code Examples 15 Safari® Books Online 15 Command-Line Options 16 Python Options 16 Program Specification 18 Environment Variables 19 Operational Variables 19 Command-Line Option Variables 20 Built-in Types and Operators 20 Operators and Precedence 20 Operator Usage Notes 22 Operations by Category 23 Sequence Operation Notes 27 Indexing: S[i] 27 Slicing: S[i:j] 27 Slicing: S[i:j:k] 28 Other 28 Specific Built-in Types 28 Numbers 28 Literals and creation 28 Operations 29 Decimal and fraction 30 Other numeric types 30 Strings 31 Literals and creation 31 Operations 33 String formatting 33 String formatting expression 34 String formatting method 35 Template string substitution 38 String methods 38 byte and bytearray methods 40 Searching 41 Splitting and joining 42 Formatting 43 Content tests 44 The original string module 44 Unicode Strings 45 Unicode support in Python 3.0 46 byte and bytearray strings 46 Unicode support in Python 2.X 47 Lists 48 Literals and creation 48 Operations 49 List comprehension expressions 50 Generator expressions 51 Other generators and comprehensions 52 Dictionaries 53 Literals and creation 53 Operations 54 Tuples 56 Literals 56 Operations 57 Files 57 Input files 58 Output files 59 Any files 59 Attributes (all read-only) 60 File context managers 60 Notes 61 Sets 61 Literals and creation 61 Operations 62 Other Common Types 63 Boolean 64 Type Conversions 64 Statements and Syntax 65 Syntax Rules 65 Name Rules 66 Name format 66 Name conventions 67 Specific Statements 68 The Assignment Statement 69 Augmented assignment 69 Normal and extended sequence assignment 70 The Expression Statement 71 Call syntax 71 Arbitrary arguments call syntax 71 The print Statement 72 Python 2.X print statements 73 The if Statement 74 The while Statement 74 The for Statement 75 The pass Statement 75 The break Statement 75 The continue Statement 76 The del Statement 76 The def Statement 76 Python 3.0 keyword-only arguments 77 Python 3.0 function annotations 78 lambda expressions 78 Defaults and attributes 78 Function and method decorators 79 The return Statement 80 The yield Statement 80 Generators and iterators 81 The global Statement 82 The nonlocal Statement 82 The import Statement 83 Package imports 84 The from Statement 84 Package relative import syntax 85 The class Statement 85 Class decorators in Python 2.6 and 3.0 86 Metaclasses 87 The try Statement 87 Python 2.X try statement forms 89 The raise Statement 90 Class exceptions 90 Python 2.X raise statement forms 91 The assert Statement 92 The with Statement 92 Multiple context managers in Python 3.1 93 Python 2.X Statements 94 Namespace and Scope Rules 94 Qualified Names: Object Namespaces 95 Unqualified Names: Lexical Scopes 95 Statically Nested Scopes 96 Object-Oriented Programming 97 Classes and Instances 97 Class objects provide default behavior 97 Instance objects are generated from classes 98 Inheritance rules 98 Pseudoprivate Attributes 98 Module privates 98 Class privates 99 New Style Classes 99 Operator Overloading Methods 100 For All Types 100 For Collections (Sequences, Mappings) 105 For Numbers (Binary Operators) 106 Basic binary methods 106 Right-side binary methods 108 Augmented binary methods 109 For Numbers (Other Operations) 109 For Descriptors 110 For Context Managers 111 Python 2.X Operator Overloading Methods 111 Methods in Python 3.0 only 111 Methods in Python 2.X only 112 Built-in Functions 114 Python 2.X Built-in Functions 131 Python 3.0 built-ins not supported by Python 2.6 131 Python 2.6 built-ins not supported by Python 3.0 131 Built-in Exceptions 136 Superclasses (Categories) 136 Specific Exceptions Raised 137 Warning Category Exceptions 141 Warnings Framework 142 Python 2.X Built-in Exceptions 143 Built-in Attributes 143 Standard Library Modules 144 The sys Module 145 The string Module 151 Module Functions and Classes 151 Constants 152 The os System Module 153 Administrative Tools 153 Portability Constants 154 Shell Commands 155 Environment Tools 156 File Descriptor Tools 157 File Pathname Tools 159 Process Control 162 The os.path Module 165 The re Pattern-Matching Module 167 Module Functions 167 Regular Expression Objects 169 Match Objects 170 Pattern Syntax 171 Object Persistence Modules 175 dbm and shelve Modules 176 pickle Module 178 Pickling interfaces 178 Unpickling interfaces 178 Usage notes 179 The tkinter GUI Module and Tools 180 tkinter Example 180 tkinter Core Widgets 181 Common Dialog Calls 182 Module tkinter.messagebox (tkMessageBox in Python 2.X) 182 Module tkinter.simpledialog (tkSimpleDialog in Python 2.X) 182 Module tkinter.colorchooser (tkColorChooser in Python 2.X) 182 Module tkinter.filedialog (tkFileDialog in Python 2.X) 182 Additional tkinter Classes and Tools 183 Tcl/Tk-to-Python/tkinter Mappings 183 Internet Modules and Tools 185 Commonly Used Library Modules 185 Other Standard Library Modules 187 The math Module 188 The time Module 188 The datetime Module 189 Threading Modules 189 Binary Data Parsing 190 Python Portable SQL Database API 191 API Usage Example 191 Module Interface 192 Connection Objects 193 Cursor Objects 193 Type Objects and Constructors 194 Python Idioms and Hints 195 Core Language Hints 195 Environment Hints 196 Usage Hints 197 Assorted Hints 199 Index 201 Table of Contents......Page 7 Introduction......Page 13 Conventions......Page 14 Safari® Books Online......Page 15 Python Options......Page 16 Program Specification......Page 18 Operational Variables......Page 19 Operators and Precedence......Page 20 Operator Usage Notes......Page 22 Operations by Category......Page 23 Slicing: S[i:j]......Page 27 Literals and creation......Page 28 Operations......Page 29 Other numeric types......Page 30 Literals and creation......Page 31 String formatting......Page 33 String formatting expression......Page 34 String formatting method......Page 35 String methods......Page 38 byte and bytearray methods......Page 40 Searching......Page 41 Splitting and joining......Page 42 Formatting......Page 43 The original string module......Page 44 Unicode Strings......Page 45 byte and bytearray strings......Page 46 Unicode support in Python 2.X......Page 47 Literals and creation......Page 48 Operations......Page 49 List comprehension expressions......Page 50 Generator expressions......Page 51 Other generators and comprehensions......Page 52 Literals and creation......Page 53 Operations......Page 54 Literals......Page 56 Files......Page 57 Input files......Page 58 Any files......Page 59 File context managers......Page 60 Literals and creation......Page 61 Operations......Page 62 Other Common Types......Page 63 Type Conversions......Page 64 Syntax Rules......Page 65 Name format......Page 66 Name conventions......Page 67 Specific Statements......Page 68 Augmented assignment......Page 69 Normal and extended sequence assignment......Page 70 Arbitrary arguments call syntax......Page 71 The print Statement......Page 72 Python 2.X print statements......Page 73 The while Statement......Page 74 The break Statement......Page 75 The def Statement......Page 76 Python 3.0 keyword-only arguments......Page 77 Defaults and attributes......Page 78 Function and method decorators......Page 79 The yield Statement......Page 80 Generators and iterators......Page 81 The nonlocal Statement......Page 82 The import Statement......Page 83 The from Statement......Page 84 The class Statement......Page 85 Class decorators in Python 2.6 and 3.0......Page 86 The try Statement......Page 87 Python 2.X try statement forms......Page 89 Class exceptions......Page 90 Python 2.X raise statement forms......Page 91 The with Statement......Page 92 Multiple context managers in Python 3.1......Page 93 Namespace and Scope Rules......Page 94 Unqualified Names: Lexical Scopes......Page 95 Statically Nested Scopes......Page 96 Class objects provide default behavior......Page 97 Module privates......Page 98 New Style Classes......Page 99 For All Types......Page 100 For Collections (Sequences, Mappings)......Page 105 Basic binary methods......Page 106 Right-side binary methods......Page 108 For Numbers (Other Operations)......Page 109 For Descriptors......Page 110 Methods in Python 3.0 only......Page 111 Methods in Python 2.X only......Page 112 Built-in Functions......Page 114 Python 2.6 built-ins not supported by Python 3.0......Page 131 Superclasses (Categories)......Page 136 Specific Exceptions Raised......Page 137 Warning Category Exceptions......Page 141 Warnings Framework......Page 142 Built-in Attributes......Page 143 Standard Library Modules......Page 144 The sys Module......Page 145 Module Functions and Classes......Page 151 Constants......Page 152 Administrative Tools......Page 153 Portability Constants......Page 154 Shell Commands......Page 155 Environment Tools......Page 156 File Descriptor Tools......Page 157 File Pathname Tools......Page 159 Process Control......Page 162 The os.path Module......Page 165 Module Functions......Page 167 Regular Expression Objects......Page 169 Match Objects......Page 170 Pattern Syntax......Page 171 Object Persistence Modules......Page 175 dbm and shelve Modules......Page 176 Unpickling interfaces......Page 178 Usage notes......Page 179 tkinter Example......Page 180 tkinter Core Widgets......Page 181 Module tkinter.filedialog (tkFileDialog in Python 2.X)......Page 182 Tcl/Tk-to-Python/tkinter Mappings......Page 183 Commonly Used Library Modules......Page 185 Other Standard Library Modules......Page 187 The time Module......Page 188 Threading Modules......Page 189 Binary Data Parsing......Page 190 API Usage Example......Page 191 Module Interface......Page 192 Cursor Objects......Page 193 Type Objects and Constructors......Page 194 Core Language Hints......Page 195 Environment Hints......Page 196 Usage Hints......Page 197 Assorted Hints......Page 199 Index......Page 201 Python is optimized for quality, productivity, portability, and integration. Hundreds of thousands of Python developers around the world rely on Python for general-purpose tasks, Internet scripting, systems programming, user interfaces, and product customization. Available on all major computing platforms, including commercial versions of Unix, Linux, Windows, and Mac OS X, Python is portable, powerful and remarkable easy to use. With its convenient, quick-reference format, Python Pocket Reference , 3rd Edition is the perfect on-the-job reference. More importantly, it's now been refreshed to cover the language's latest release, Python 2.4. For experienced Python developers, this book is a compact toolbox that delivers need-to-know information at the flip of a page. This third edition also includes an easy-lookup index to help developers find answers fast! Python 2.4 is more than just optimization and library enhancements; it's also chock full of bug fixes and upgrades. And these changes are addressed in the Python Pocket Reference , 3rd Edition. New language features, new and upgraded built-ins, and new and upgraded modules and packages—they're all clarified in detail. The Python Pocket Reference , 3rd Edition serves as the perfect companion to (/works/OL2784125W/) Learning Python and Programming Python . Revision History October 1998 First Edition January 2002 Second Edition February 2005 Third Edition October 2009 Fourth Edition 5th Edition 2014-01-17 First release 2014-02-14 Second release 2015-02-06 Third release 2018-08-10 Fourth release 2018-11-21 Fifth release This is the book to reach for when you're coding on the fly and need an answer now. It's an easy-to-use reference to the core language, with descriptions of commonly used modules and toolkits, and a guide to recent changes, new features, and upgraded built-ins -- all updated to cover Python 3.X as well as version 2.6. You'll also quickly find exactly what you need with the handy index. Written by Mark Lutz -- widely recognized as the world's leading Python trainer -- Python Pocket Reference, Fourth Edition, is the perfect companion to O'Reilly's classic Python tutorials, also written by Mark: Learning Python and Programming Python. Built-in object types, including numbers, lists, dictionaries, and more Statements and syntax for creating and processing objects Functions and modules for structuring and reusing code Python's object-oriented programming tools The exception-handling model Built-in functions, exceptions, and attributes Special operator overloading methods Widely used standard library modules and extensions Command-line options and development tools Python idioms and hints Provides descriptions of commonly used modules and toolkits along with information on recent changes, new features, and upgraded built-ins for Python 3.X and version 2.6.