Buch, Englisch, 1048 Seiten, Format (B × H): 178 mm x 254 mm
Reihe: Rheinwerk Computing
The Comprehensive Guide
Buch, Englisch, 1048 Seiten, Format (B × H): 178 mm x 254 mm
Reihe: Rheinwerk Computing
ISBN: 978-1-4932-2800-3
Verlag: Rheinwerk Verlag GmbH
Ready to master Python? In this updated edition of the prize-winning Python reference, learn to write effective code, whether you’re a beginner or a professional programmer. Review core Python concepts, including functions, modularization, and object orientation, and walk through the available data types. Then dive into more advanced topics, such as exception handling, static type checking, and regular expressions. With mountains of code examples throughout, this hands-on reference guide has everything you need to become proficient in Python!
Highlights includes:
1) Functions
2) Methods
3) Attributes
4) Data types
5) GUIs
6) Debugging
7) Network communication
8) Modularization
9) Object orientation
10) Iterators
11)Generators
12)Exception handling
Autoren/Hrsg.
Fachgebiete
Weitere Infos & Material
1 ... Introduction ... 31
1.1 ... Why Did We Write This Book? ... 31
1.2 ... What Does This Book Provide? ... 32
1.3 ... Structure of the Book ... 32
1.4 ... How Should You Read This Book? ... 33
1.5 ... Sample Programs ... 34
1.6 ... Preface to the Second English Edition (2026) ... 34
1.7 ... Acknowledgments ... 35
2 ... The Python Programming Language ... 37
2.1 ... History and Origin ... 37
2.2 ... Basic Concepts ... 38
2.3 ... Possible Areas of Use and Strengths ... 39
2.4 ... Installing Python ... 40
2.5 ... Installing Third-Party Modules ... 43
2.6 ... Using Python ... 43
PART I ... Getting Started with Python ... 45
3 ... Getting Started with the Interactive Mode ... 47
3.1 ... Integers ... 47
3.2 ... Floats ... 49
3.3 ... Character Strings ... 49
3.4 ... Lists ... 50
3.5 ... Dictionaries ... 51
3.6 ... Variables ... 52
3.7 ... Logical Expressions ... 53
3.8 ... Functions and Methods ... 55
3.9 ... Screen Outputs ... 57
3.10 ... Modules ... 58
4 ... The Path to the First Program ... 61
4.1 ... Typing, Compiling, and Testing ... 61
4.2 ... Basic Structure of a Python Program ... 64
4.3 ... The First Program ... 67
4.4 ... Comments ... 69
4.5 ... In Case of Error ... 70
5 ... Control Structures ... 73
5.1 ... Conditionals ... 73
5.2 ... Loops ... 77
5.3 ... The pass Statement ... 84
5.4 ... Assignment Expressions ... 84
6 ... Files ... 89
6.1 ... Data Streams ... 89
6.2 ... Reading Data from a File ... 90
6.3 ... Writing Data to a File ... 94
6.4 ... Generating the File Object ... 95
7 ... The Data Model ... 101
7.1 ... The Structure of Instances ... 103
7.2 ... Deleting References ... 107
7.3 ... Mutable Versus Immutable Data Types ... 109
8 ... Functions, Methods, and Attributes ... 113
8.1 ... Parameters of Functions and Methods ... 113
8.2 ... Attributes ... 116
9 ... Sources of Information on Python ... 117
9.1 ... The Built-In Help Function ... 117
9.2 ... The Online Documentation ... 118
9.3 ... PEPs ... 118
PART II ... Data Types ... 121
10 ... Basic Data Types: An Overview ... 123
10.1 ... Nothingness: NoneType ... 124
10.2 ... Operators ... 125
11 ... Numeric Data Types ... 129
11.1 ... Arithmetic Operators ... 129
11.2 ... Comparison Operators ... 131
11.3 ... Conversion between Numeric Data Types ... 132
11.4 ... Integers: int ... 133
11.5 ... Floats: float ... 139
11.6 ... Boolean Values: bool ... 142
11.7 ... Complex Numbers: complex ... 147
12 ... Sequential Data Types ... 151
12.1 ... The Difference Between Text and Binary Data ... 151
12.2 ... Operations on Instances of Sequential Data Types ... 152
12.3 ... The list Data Type ... 164
12.4 ... Immutable Lists: tuple ... 177
12.5 ... Strings: str, bytes, bytearray ... 180
13 ... Mappings and Sets ... 217
13.1 ... Dictionary: dict ... 217
13.2 ... Sets: set and frozenset ... 229
14 ... Collections ... 243
14.1 ... Chained Dictionaries ... 243
14.2 ... Counting Frequencies ... 244
14.3 ... Dictionaries with Default Values ... 246
14.4 ... Doubly Linked Lists ... 247
14.5 ... Named Tuples ... 249
15 ... Date and Time ... 251
15.1 ... Elementary Time Functions: time ... 251
15.2 ... Object-Oriented Date Management: datetime ... 259
15.3 ... Time Zones: zoneinfo ... 268
16 ... Enumerations and Flags ... 273
16.1 ... Enumeration Types: enum ... 273
16.2 ... Enumeration Types for Bit Patterns: Flag ... 275
16.3 ... Integer Enumeration Types: IntEnum ... 276
PART III ... Advanced Programming Techniques ... 277
17 ... Functions ... 279
17.1 ... Defining a Function ... 280
17.2 ... Return Values ... 282
17.3 ... Function Objects ... 284
17.4 ... Optional Parameters ... 284
17.5 ... Keyword Arguments ... 285
17.6 ... Arbitrarily Many Parameters ... 286
17.7 ... Keyword-Only Parameters ... 288
17.8 ... Positional-Only Parameters ... 289
17.9 ... Unpacking When Calling a Function ... 290
17.10 ... Side Effects ... 293
17.11 ... Namespaces ... 295
17.12 ... Anonymous Functions ... 301
17.13 ... Recursion ... 302
17.14 ... Built-In Functions ... 303
18 ... Modules and Packages ... 327
18.1 ... Importing Global Modules ... 328
18.2 ... Local Modules ... 330
18.3 ... Packages ... 332
18.4 ... The importlib Package ... 336
18.5 ... Planned Language Elements ... 337
19 ... Object-Oriented Programming ... 339
19.1 ... Example: A Non-Object-Oriented Account ... 339
19.2 ... Classes ... 344
19.3 ... Inheritance ... 349
19.4 ... Multiple Inheritance ... 361
19.5 ... Property Attributes ... 363
19.6 ... Static Methods ... 365
19.7 ... Class Methods ... 367
19.8 ... Class Attributes ... 368
19.9 ... Built-in Functions for Object-Oriented Programming ... 369
19.10 ... Inheriting Built-In Data Types ... 372
19.11 ... Magic Methods and Magic Attributes ... 374
19.12 ... Data Classes ... 393
20 ... Exception Handling ... 399
20.1 ... Exceptions ... 399
20.2 ... Assertions ... 414
20.3 ... Warnings ... 415
20.4 ... Exception Groups ... 416
21 ... Generators and Iterators ... 421
21.1 ... Generators ... 421
21.2 ... Iterators ... 428
21.3 ... Special Generators: itertools ... 437
21.4 ... Generators as Consumers ... 446
22 ... Context Manager ... 453
22.1 ... The with Statement ... 453
22.2 ... Helper Functions for with Contexts: contextlib ... 456
23 ... Decorators ... 461
23.1 ... Function Decorators ... 461
23.2 ... Class Decorators ... 466
23.3 ... The functools Module ... 467
24 ... Annotations for Static Type Checking ... 473
24.1 ... Annotations ... 474
24.2 ... Type Hints: The typing Module ... 481
24.3 ... Static Type Checking in Python: mypy ... 487
25 ... Structural Pattern Matching ... 489
25.1 ... The match Statement ... 489
25.2 ... Pattern Types in the case Statement ... 490
PART IV ... The Standard Library ... 505
26 ... Mathematics ... 507
26.1 ... Mathematical Functions: math, cmath ... 507
26.2 ... Random Number Generator: random ... 513
26.3 ... Statistical Calculations: statistics ... 517
26.4 ... Intuitive Decimal Numbers: decimal ... 518
26.5 ... Hash Functions: hashlib ... 524
27 ... Screen Outputs and Logging ... 531
27.1 ... Formatted Output of Complex Objects: pprint ... 531
27.2 ... Log Files: logging ... 533
28 ... Regular Expressions ... 539
28.1 ... Syntax of Regular Expressions ... 539
28.2 ... Using the re Module ... 549
28.3 ... A Simple Sample Program: Searching ... 555
28.4 ... A More Complex Sample Program: Matching ... 556
28.5 ... Comments in Regular Expressions ... 559
28.6 ... Catastrophic Backtracking ... 560
29 ... Interface to Operating System and Runtime Environment ... 563
29.1 ... Operating System Functionality: os ... 563
29.2 ... Starting Subprocesses: subprocess ... 565
29.3 ... Accessing the Runtime Environment: sys ... 568
29.4 ... Command Line Parameters: argparse ... 573
30 ... File System ... 581
30.1 ... Basics of File Systems and Paths ... 581
30.2 ... The Modern Approach: pathlib ... 583
30.3 ... Accessing the File System: os ... 589
30.4 ... File Paths: os.path ... 595
30.5 ... Accessing the File System: shutil ... 600
30.6 ... Temporary Files: tempfile ... 605
31 ... Parallel Programming ... 607
31.1 ... Processes, Multitasking, and Threads ... 607
31.2 ... Python's Interfaces for Parallelization ... 611
31.3 ... The Abstract Interface: concurrent.futures ... 612
31.4 ... The Flexible Interface: threading and multiprocessing ... 622
31.5 ... Cooperative Multitasking ... 633
31.6 ... Conclusion: Which Interface Is the Right One? ... 649
32 ... Data Storage ... 651
32.1 ... The JSON Data Exchange Format: json ... 651
32.2 ... Serializing Instances: pickle ... 652
32.3 ... The CSV Table Format: csv ... 656
32.4 ... Compressed Files and Archives ... 661
32.5 ... Databases ... 663
32.6 ... XML ... 681
33 ... Network Communication ... 695
33.1 ... Socket API ... 696
33.2 ... XML-RPC ... 712
34 ... Accessing Resources on the Internet ... 721
34.1 ... Protocols ... 721
34.2 ... Solutions ... 722
34.3 ... The Easy Way: requests ... 722
34.4 ... URLs: urllib ... 725
34.5 ... FTP: ftplib ... 733
35 ... Email ... 739
35.1 ... SMTP: smtplib ... 739
35.2 ... POP3: poplib ... 742
35.3 ... IMAP4: imaplib ... 746
35.4 ... Creating Complex Emails: email ... 751
36 ... Debugging and Quality Assurance ... 755
36.1 ... The Debugger ... 755
36.2 ... Automated Testing ... 757
36.3 ... Analyzing the Runtime Performance ... 765
37 ... Documentation ... 775
37.1 ... Docstrings ... 775
37.2 ... Automatically Generated Documentation: pydoc ... 777
PART V ... Advanced Topics ... 779
38 ... Distributing Python Projects ... 781
38.1 ... A History of Distributions in Python ... 781
38.2 ... Creating Distributions: setuptools ... 782
38.3 ... Creating EXE files: cx_Freeze ... 790
38.4 ... Package Manager ... 792
38.5 ... Localizing Programs: gettext ... 797
39 ... Virtual Environments ... 801
39.1 ... Using Virtual Environments: venv ... 802
39.2 ... Virtual Environments in Anaconda ... 803
40 ... Alternative Interpreters and Compilers ... 805
40.1 ... Just-in-Time Compilation: PyPy ... 805
40.2 ... Numba ... 806
40.3 ... Connecting to C and C++: Cython ... 809
40.4 ... The Interactive Python Shell: IPython ... 815
41 ... Graphical User Interfaces ... 823
41.1 ... Toolkits ... 823
41.2 ... Introduction to tkinter ... 825
41.3 ... Introduction to PySide6 ... 866
42 ... Python as a Server-Side Programming Language on the Web: An Introduction to Django ... 911
42.1 ... Concepts and Features of Django ... 912
42.2 ... Installing Django ... 913
42.3 ... Creating a New Django Project ... 914
42.4 ... Creating an Application ... 917
43 ... Scientific Computing and Data Science ... 953
43.1 ... Installation ... 954
43.2 ... The Model Program ... 954
43.3 ... Overview of the numpy and scipy Modules ... 962
43.4 ... An Introduction to Data Analysis with pandas ... 971
44 ... Inside Knowledge ... 987
44.1 ... Opening URLs in the Default Browser: webbrowser ... 987
44.2 ... Interpreting Binary Data: struct ... 987
44.3 ... Hidden Password Entry ... 989
44.4 ... Command Line Interpreter ... 990
44.5 ... File Interface for Strings: io.StringIO ... 993
44.6 ... Copying Instances: copy ... 994
44.7 ... Image Processing: Pillow ... 997
45 ... A History of Python Versions ... 1007
45.1 ... Python’s Version History ... 1007
45.2 ... The Leap to Python 3 ... 1010
A ... Appendix ... 1017
A.1 ... Reserved Words ... 1017
A.2 ... Operator Precedence ... 1017
A.3 ... Built-In Functions ... 1019
A.4 ... Built-In Exceptions ... 1023
A.5 ... Python IDEs ... 1027
... The Authors ... 1029
... Index ... 1031




