Python reference Manual (fourth edition) "PDF" Download

Source: Internet
Author: User
Tags pack

Python reference Manual (fourth edition) "PDF" Download Link:
https://u253469.pipipan.com/fs/253469-230382222

Content Introduction

This book is the authoritative Python Language Reference guide that covers the most important parts of the core Python language and the Python library. The book contains some high-level topics that are not included in official Python documents or other materials, and are concise and readable.

This edition is fully updated on the content, introducing the new programming language features and library modules introduced in Python 2.6 and Python 3, as well as analyzing the challenges that Python programmers face: whether to continue using existing Python code or plan to port it to Python
3?

Author Introduction

David M. Beazley began to use Python programming as early as 1996. While working at the Los Alamos National Laboratory, he taught many volunteers to write scientific computing software in Python. The Dabeaz he founded
The company provides software development, training and consulting services, specialising in the practical application of Python, Ruby, Perl and other dynamic programming languages. He is a member of the Python Software Foundation.

Directory

The first part of the Python language
1th Chapter
About Python
2
1.1
Run Python
2
1.2
Variables and arithmetic Expressions 3
1.3
Conditional Statement 5
1.4
File input and Output 6
1.5
String 7
1.6
Listing 8
1.7
Tuple 9
1.8
Collection 10
1.9
Dictionary 11
1.10
Iterations and Loops 12
1.11
function 13
1.12
Generator 14
1.13
Co-process 15
1.14
Objects and Classes 16
1.15
Exception 17
1.16
Module 18
1.17
Get help 19
2nd Chapter
Vocabulary and Grammar Conventions 20
2.1
Row structure and indentation 20
2.2
Identifiers and reserved words 21
2.3
Digital literal 21
2.4
string literal 22
2.5
Container 23
2.6
Operators, separators, and special symbols 24
2.7
Document String 24
2.8
Adorner 24
2.9
Source Code 25
3rd Chapter
Type and Object 26
3.1
Terminology 26
3.2
Identity and type of object 26
3.3
Reference counting and garbage collection 27
3.4
References and Replication 28
3.5
First Class object 29
3.6
Represents the built-in type of data 30
3.6.1
None Type 30
3.6.2
Number Type 31
3.6.3
Sequence Type 31
3.6.4
Mapping Type 35
3.6.5
Collection type 36
3.7
Represents the built-in type of the program structure 37
3.7.1
Callable Type 38
3.7.2
classes, types, and instances 40
3.7.3
Module 41
3.8
Built-in types used inside the interpreter 41
3.8.1
Code Object 41
3.8.2
Frame Object 42
3.8.3
Tracking Objects 42
3.8.4
Builder Object 43
3.8.5
Slicing Objects 43
3.8.6
Ellipsis Object 43
3.9
Object behavior and Special methods 44
3.9.1
Creation and destruction of objects 44
3.9.2
Object string Representation 44
3.9.3
Object comparison and Sorting 45
3.9.4
Type checking 46
3.9.5
Property Access 46
3.9.6
Property wrapper with descriptor 46
3.9.7
Sequence and Mapping method 47
3.9.8
Iteration 48
3.9.9
Math Operations 48
3.9.10
Callable Interface 50
3.9.11
Context Management Protocol 50
3.9.12
Object Check with Dir ()
51
4th Chapter
Operators and Expressions 52
4.1
Digital Operations 52
4.2
Sequence Action 53
4.3
String Formatting 56
4.4
Advanced String Formatting 57
4.5
Dictionary Operation 59
4.6
Collection Operations 60
4.7
Increment Assignment 60
4.8
Property (.) operator 61
4.9
function call () operator 61
4.10
Conversion function 61
4.11
Boolean expression and Truth 62
4.12
Comparison and identity of objects 63
4.13
Operation Priority 63
4.14
Conditional Expression 64
5th Chapter
Program structure and control flow 65
5.1
Program Structure and execution 65
5.2
Execute Conditional Statement 65
5.3
Loops and Iterations 66
5.4
Exception 68
5.4.1
Built-in exception 70
5.4.2
Defining a new Exception 71
5.5
Context Manager and with statement 72
5.6
Assertions and __debug__
73
6th Chapter
function and function Programming 75
6.1
Function 75
6.2
Parameter passing and return value 77
6.3
Scope Rule 77
6.4
function objects and closures 79
6.5
Adorner 82
6.6
Generator and yield
83
6.7
Co-and yield expressions 85
6.8
Using the generator and the coprocessor 87
6.9
List contains 89
6.10
Generator Expression 90
6.11
Declarative Programming 91
6.12
Lambda operator 92
6.13
Recursive 92
6.14
Document String 93
6.15
Function Properties 94
6.16
Eval_r (), exec (), and compile () functions 94
7th Chapter
Class and object-oriented programming 96
7.1
Class Statement 96
7.2
class Instance 97
7.3
Scope Rule 97
7.4
Inheritance 98
7.5
polymorphic dynamic binding and Duck type 100
7.6
Static methods and Class methods 101
7.7
Feature 102
7.8
Descriptor 104
7.9
Data encapsulation and private properties 105
7.10
Object Memory Management 106
7.11
Object representations and property bindings 108
7.12
__SLOTS__ 109
7.13
Operator Overloading 110
7.14
Type and class member Test 111
7.15
Abstract base class 113
7.16
Meta-Class 114
7.17
Class Adorner 117
8th Chapter
Modules, packages and distributions 118
8.1
Module and import statement 118
8.2
Import selected symbols from module 119
8.3
EXECUTE AS Main program 120
8.4
Module Search Path 121
8.5
Module loading and compiling 121
8.6
Module Reload and unload 122
8.7
Pack 123
8.8
Distributing Python programs and libraries 125
8.9
Installing third-party libraries 127
9th Chapter
Input and output 129
9.1
Read command-line Options 129
9.2
Environment Variables 130
9.3
File and File Objects 130
9.4
Standard input, output, and error 133
9.5
Print Statement 133
9.6
Print () function 134
9.7
Variable insertion in text output 134
9.8
Build output 135
9.9
Unicode string Processing 136
9.10
Unicode I/O 137
9.10.1
Unicode data Encoding 138
9.10.2
Unicode character attribute 140
9.11
Object persistence with pickle module 140
10th Chapter
Execution Environment 142
10.1
Interpreter options and Environment 142
10.2
Interactive session 144
10.3
Launching the Python application 145
10.4
Site configuration file 145
10.5
User Site Pack 146
10.6
Enabling new features 146
10.7
Program Termination 147
11th Chapter
Testing, commissioning, probing, and tuning 149
11.1
Document strings and Doctest modules 149
11.2
Unit test and UnitTest module 151
11.3
Python Debugger and PDB module 153
11.3.1
Debugger Commands 153
11.3.2
Debugging from the command line 156
11.3.3
Configuring the Debugger 156
11.4
Program Sniffing 156
11.5
Tuning and Optimization 157
11.5.1
Perform a timing measurement 157
11.5.2
Making memory Measurements 158
11.5.3
Anti-Assembly 158
11.5.4
Tuning Strategy 159
Part II
Python Library
12th Chapter
Built-in functions and exceptions 164
12.1
Built-in functions and types 164
12.2
Built-in Exception 172
12.2.1
Exception base class 172
12.2.2
Exception Instance 173
12.2.3
Pre-defined Exception class 173
12.3
Built-in warning 176
12.4
Future_builtins 176
13th Chapter
Python Run-Time service
178
13.1
Atexit 178
13.2
Copy 178
13.3
GC 179
13.4
Inspect 180
13.5
Marshal 183
13.6
Pickle 184
13.7
SYS 186
13.7.1
Variable 186
13.7.2
Function 189
13.8
Traceback 191
13.9
Types 192
13.10
Warnings 193
13.11
Weakref 194
14th Chapter
Mathematical Operations 197
14.1
Decimal 197
14.1.1
Decimal Object 197
14.1.2
Context Object 198
14.1.3
Functions and Constants 200
14.1.4
Example 201
14.2
Fractions 202
14.3
Math 203
14.4
Numbers 205
14.5
Random 206
14.5.1
Seeding and initializing 206
14.5.2
Random integer 206
14.5.3
Random Sequence 206
14.5.4
Real-valued random distribution 207
15th Chapter
Data structure, algorithms, and code simplification 209
15.1
ABC 209
15.2
Array 210
15.3
Bisect 212
15.4
Collections 213
15.4.1
Deque and Defaultdict
213
15.4.2
Named Tuples 214
15.4.3
Abstract base class 216
15.5
Contextlib 217
15.6
Functools 218
15.7
HEAPQ 219
15.8
Itertools 220
15.9
Operator 222
16th Chapter
string and Text Processing 225
16.1
Odecs 225
16.1.1
Low-level codecs interface 225
16.1.2
I/O correlation function 226
16.1.3
Useful Constants 227
16.1.4
Standard Code 227
16.1.5
Note 228
16.2
Re 228
16.2.1
Pattern Syntax 228
16.2.2
Function 229
16.2.3
Regular Expression Object 231
16.2.4
Matching Objects 231
16.2.5
Example 232
16.2.6
Note 233
16.3
String 233
16.3.1
Constant 233
16.3.2
Formatter Object 233
16.3.3
Template String 235
16.3.4
Utility Functions 235
16.4
struct 235
16.4.1
Packaging and unpacking functions 236
16.4.2
struct Object 236
16.4.3
Format Code 236
16.4.4
Note 237
16.5
Unicodedata 238
17th Chapter
Python database access
241
17.1
Relational database API Specification 241
17.1.1
Connection 241
17.1.2
Cursor 242
17.1.3
Build Query 243
17.1.4
Type Object 244
17.1.5
Error handling 245
17.1.6
Multithreading 245
17.1.7
Map the results to the dictionary 246
17.1.8
Database API Extensions 246
17.2
Sqlite3 Module 246
17.2.1
Module-level Functions 246
17.2.2
Connection Object 248
17.2.3
Cursors and basic Operations 250
17.3
DBM-style Database module 252
17.4
Shelve Module 253
18th Chapter
File and directory processing 254
18.1
BZ2 254
18.2
FILECMP 255
18.3
Fnmatch 256
18.4
Glob 257
18.5
Gzip 257
18.6
Shutil 258
18.7
Tarfile 259
18.7.1
Exception 261
18.7.2
Example 262
18.8
Tempfile 262
18.9
ZipFile 263
18.10
Zlib 266
19th Chapter
Operating System Services 268
19.1
Commands Module 268
19.2
Configparser, Configparser module 269
19.2.1
Configparser class 269
19.2.2
Example 270
19.2.3
Note 272
19.3
DateTime Module 272
19.3.1
Date Object 272
19.3.2
Time Object 273
19.3.3
DateTime Object 274
19.3.4
Timedelta Object 275
19.3.5
Mathematical operations involving dates 276
19.3.6
Tzinfo Object 277
19.3.7
Date and time resolution 278
19.4
errno Module 278
19.4.1
POSIX error code 278
19.4.2
Windows Error Code 279
19.5
FCNTL Module 280
19.5.1
Example 281
19.5.2
Note 282
19.6
IO module 282
19.6.1
Basic I/O interface 282
19.6.2
Raw I/O
282
19.6.3
Cache binary I/O
283
19.6.4
Text I/O
285
19.6.5
Open () function 285
19.6.6
Abstract base class 286
19.7
Logging Module 286
19.7.1
Logging Level 286
19.7.2
Basic Configuration 287
19.7.3
Logger Object 288
19.7.4
Processor Object 292
19.7.5
Message Formatting 295
19.7.6
Various utility Functions 296
19.7.7
Logging Configuration 296
19.7.8
Performance Considerations 299
19.7.9
Note 299
19.8
MMAP Module 299
19.9
MSVCRT Module 301
19.10
Optparse Module 303
19.10.1
Example 305
19.10.2
Note 306
19.11
OS Module 307
19.11.1
Process Environment 307
19.11.2
File creation with file Descriptor 309
19.11.3
Files and directories 313
19.11.4
Process Management 316
19.11.5
System Configuration 320
19.11.6
Exception 321
19.12
Os.path Module 321
19.13
Signal Module 323
19.13.1
Example 325
19.13.2
Note 325
19.14
Subprocess Module 326
19.14.1
Example 327
19.14.2
Note 328
19.15
Time Module 328
19.16
WinReg Module 331
20th Chapter
Threading and Concurrency 334
20.1
Basic Concepts 334
20.2
Concurrent programming with Python
335
20.3
Multiprocessing Module 336
20.3.1
Process 336
20.3.2
Inter-process Communication 337
20.3.3
Process Pool 343
20.3.4
Shared data and synchronization 345
20.3.5
Managed Objects 347
20.3.6
Connection 352
20.3.7
Various utility Functions 353
20.3.8
General recommendations for multi-process processing 353
20.4
Threading Module 354
20.4.1
Thread Object 354
20.4.2
Timer Object 356
20.4.3
Lock Object 356
20.4.4
Rlock 356
20.4.5
Signal volume with bounded signal 357
20.4.6
Event 358
20.4.7
Condition Variable 358
20.4.8
Use lock
359
20.4.9
Thread Termination and Suspend 360
20.4.10
Utility Functions 361
20.4.11
Global Interpreter Lock 361
20.4.12
Using Thread Programming 361
20.5
Queue, Queue module 362
20.6
Process and micro-threading 364
21st Chapter
Network programming and Sockets 365
21.1
Fundamentals of Network Programming 365
21.2
Asynchat Module 367
21.3
Asyncore Module 370
21.4
Select 374
21.4.1
Advanced module Features 375
21.4.2
Advanced asynchronous I/O example 375
21.4.3
Timing of asynchronous Networking 381
21.5
Socket 383
21.5.1
Address Family 383
21.5.2
Socket Type 383
21.5.3
Addressing 384
21.5.4
function 385
21.5.5
Exception 395
21.5.6
Example 395
21.5.7
Note 396
21.6
SSL 396
21.7
Socketserver 399
21.7.1
Handlers 399
21.7.2
Server 400
21.7.3
Defining a custom Server 401
21.7.4
Custom Application Server 403
22nd Chapter
Internet application Programming
404
22.1
Ftplib 404
22.2
HTTP Package 407
22.2.1
Http.client (httplib) 408
22.2.2
Http.server (basehttp-server,cgihttpserver,simplehttp server)
412
22.2.3
Http.cookies (Cookie) 416
22.2.4
Http.cookiejar (cookielib) 418
22.3
Smtplib 418
22.4
Urllib Pack 419
22.4.1
Urllib.request (URLLIB2) 419
22.4.2
Urllib.response 423
22.4.3
Urllib.parse 424
22.4.4
Urllib.error 426
22.4.5
Urllib.robotparser (Robotparser) 427
22.4.6
Note 427
22.5
XMLRPC Pack 427
22.5.1
Xmlrpc.client (xmlrpclib) 427
22.5.2
Xmlrpc.server (simple-xmlrpcserver,docxmlr-pcserver) 430

...

For more information please follow my Sina blog http://blog.sina.com.cn/u/3283485963
Python reference Manual (fourth edition) "PDF" Download Link:
https://u253469.pipipan.com/fs/253469-230382222

For more books and recommended ebooks, please pay attention to:
http://zhaozhiyong.cn

Python reference Manual (fourth edition) "PDF" Download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.