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
Author(s): Mark Lutz
Series: Pocket Reference (O'Reilly)
Edition: Fourth Edition
Publisher: O'Reilly Media
Year: 2009
Language: English
Pages: 210
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