ISBN-13: 9781493223022 / Angielski / Miękka / 2022 / 1036 str.
ISBN-13: 9781493223022 / Angielski / Miękka / 2022 / 1036 str.
1 ... Introduction ... 33
1.1 ... Why Did We Write This Book? ... 33
1.2 ... What Does This Book Provide? ... 34
1.3 ... Structure of the Book ... 34
1.4 ... How Should You Read This Book? ... 35
1.5 ... Sample Programs ... 36
1.6 ... Preface To the First English Edition (2022) ... 36
1.7 ... Acknowledgments ... 37
2 ... The Python Programming Language ... 39
2.1 ... History, Concepts, and Areas of Application ... 39
2.2 ... Installing Python ... 42
2.3 ... Installing Third-Party Modules ... 45
2.4 ... Using Python ... 45
PART I ... Getting Started with Python ... 47
3 ... Getting Started with the Interactive Mode ... 49
3.1 ... Integers ... 49
3.2 ... Floats ... 51
3.3 ... Character Strings ... 51
3.4 ... Lists ... 52
3.5 ... Dictionaries ... 53
3.6 ... Variables ... 54
3.7 ... Logical Expressions ... 55
3.8 ... Functions and Methods ... 57
3.9 ... Screen Outputs ... 59
3.10 ... Modules ... 60
4 ... The Path to the First Program ... 63
4.1 ... Typing, Compiling, and Testing ... 63
4.2 ... Basic Structure of a Python Program ... 66
4.3 ... The First Program ... 70
4.4 ... Comments ... 72
4.5 ... In Case of Error ... 72
5 ... Control Structures ... 75
5.1 ... Conditionals ... 75
5.2 ... Loops ... 79
5.3 ... The pass Statement ... 87
5.4 ... Assignment Expressions ... 87
6 ... Files ... 91
6.1 ... Data Streams ... 91
6.2 ... Reading Data from a File ... 92
6.3 ... Writing Data to a File ... 96
6.4 ... Generating the File Object ... 97
7 ... The Data Model ... 103
7.1 ... The Structure of Instances ... 105
7.2 ... Deleting References ... 109
7.3 ... Mutable versus Immutable Data Types ... 111
8 ... Functions, Methods, and Attributes ... 115
8.1 ... Parameters of Functions and Methods ... 115
8.2 ... Attributes ... 118
9 ... Sources of Information on Python ... 119
9.1 ... The Built-In Help Function ... 119
9.2 ... The Online Documentation ... 120
9.3 ... PEPs ... 120
PART II ... Data Types ... 123
10 ... Basic Data Types: An Overview ... 125
10.1 ... Nothingness: NoneType ... 126
10.2 ... Operators ... 127
11 ... Numeric Data Types ... 131
11.1 ... Arithmetic Operators ... 131
11.2 ... Comparison Operators ... 133
11.3 ... Conversion between Numeric Data Types ... 134
11.4 ... Integers: int ... 135
11.5 ... Floats: float ... 141
11.6 ... Boolean Values: bool ... 144
11.7 ... Complex Numbers: complex ... 149
12 ... Sequential Data Types ... 153
12.1 ... The Difference between Text and Binary Data ... 153
12.2 ... Operations on Instances of Sequential Data Types ... 154
12.3 ... The list Data Type ... 166
12.4 ... Immutable Lists: tuple ... 179
12.5 ... Strings: str, bytes, bytearray ... 182
13 ... Mappings and Sets ... 215
13.1 ... Dictionary: dict ... 215
13.2 ... Sets: set and frozenset ... 227
14 ... Collections ... 239
14.1 ... Chained Dictionaries ... 239
14.2 ... Counting Frequencies ... 240
14.3 ... Dictionaries with Default Values ... 242
14.4 ... Doubly Linked Lists ... 243
14.5 ... Named Tuples ... 245
15 ... Date and Time ... 247
15.1 ... Elementary Time Functions-time ... 247
15.2 ... Object-Oriented Date Management: datetime ... 254
15.3 ... Time Zones: zoneinfo ... 263
16 ... Enumerations and Flags ... 269
16.1 ... Enumeration Types: enum ... 269
16.2 ... Enumeration Types for Bit Patterns: flag ... 271
16.3 ... Integer Enumeration Types: IntEnum ... 272
PART III ... Advanced Programming Techniques ... 275
17 ... Functions ... 277
17.1 ... Defining a Function ... 278
17.2 ... Return Values ... 280
17.3 ... Function Objects ... 282
17.4 ... Optional Parameters ... 282
17.5 ... Keyword Arguments ... 283
17.6 ... Arbitrarily Many Parameters ... 284
17.7 ... Keyword-Only Parameters ... 286
17.8 ... Positional-Only Parameters ... 287
17.9 ... Unpacking When Calling a Function ... 288
17.10 ... Side Effects ... 290
17.11 ... Namespaces ... 293
17.12 ... Anonymous Functions ... 299
17.13 ... Recursion ... 300
17.14 ... Built-In Functions ... 300
18 ... Modules and Packages ... 325
18.1 ... Importing Global Modules ... 326
18.2 ... Local Modules ... 328
18.3 ... Packages ... 331
18.4 ... The importlib Package ... 335
18.5 ... Planned Language Elements ... 338
19 ... Object-Oriented Programming ... 341
19.1 ... Example: A Non-Object-Oriented Account ... 341
19.2 ... Classes ... 346
19.3 ... Inheritance ... 351
19.4 ... Multiple Inheritance ... 363
19.5 ... Property Attributes ... 365
19.6 ... Static Methods ... 367
19.7 ... Class Methods ... 369
19.8 ... Class Attributes ... 370
19.9 ... Built-in Functions for Object-Oriented Programming ... 370
19.10 ... Inheriting Built-In Data Types ... 373
19.11 ... Magic Methods and Magic Attributes ... 375
19.12 ... Data Classes ... 393
20 ... Exception Handling ... 399
20.1 ... Exceptions ... 399
20.2 ... Assertions ... 411
20.3 ... Warnings ... 412
21 ... Generators and Iterators ... 415
21.1 ... Generators ... 415
21.2 ... Iterators ... 422
21.3 ... Special Generators: itertools ... 432
22 ... Context Manager ... 441
22.1 ... The with Statement ... 441
22.2 ... Helper Functions for with Contexts: contextlib ... 444
23 ... Decorators ... 449
23.1 ... Function Decorators ... 449
23.2 ... Class Decorators ... 454
23.3 ... The functools Module ... 455
24 ... Annotations for Static Type Checking ... 463
24.1 ... Annotations ... 464
24.2 ... Type Hints: The typing Module ... 471
24.3 ... Static Type Checking in Python: mypy ... 476
25 ... Structural Pattern Matching ... 479
25.1 ... The match Statement ... 479
25.2 ... Pattern Types in the case Statement ... 480
PART IV ... The Standard Library ... 495
26 ... Mathematics ... 497
26.1 ... Mathematical Functions: math, cmath ... 497
26.2 ... Random Number Generator: random ... 503
26.3 ... Statistical Calculations: statistics ... 507
26.4 ... Intuitive Decimal Numbers: decimal ... 509
26.5 ... Hash Functions: hashlib ... 514
27 ... Screen Outputs and Logging ... 521
27.1 ... Formatted Output of Complex Objects: pprint ... 521
27.2 ... Log Files: logging ... 523
28 ... Regular Expressions ... 529
28.1 ... Syntax of Regular Expressions ... 529
28.2 ... Using the re Module ... 539
28.3 ... A Simple Sample Program: Searching ... 546
28.4 ... A More Complex Sample Program: Matching ... 547
28.5 ... Comments in Regular Expressions ... 550
29 ... Interface to Operating System and Runtime Environment ... 553
29.1 ... Operating System Functionality: os ... 553
29.2 ... Accessing the Runtime Environment: sys ... 555
29.3 ... Command Line Parameters: argparse ... 561
30 ... File System ... 569
30.1 ... Accessing the File System: os ... 569
30.2 ... File Paths: os.path ... 575
30.3 ... Accessing the File System: shutil ... 579
30.4 ... Temporary Files: tempfile ... 585
31 ... Parallel Programming ... 587
31.1 ... Processes, Multitasking, and Threads ... 587
31.2 ... Python's Interfaces for Parallelization ... 591
31.3 ... The Abstract Interface: concurrent.futures ... 592
31.4 ... The Flexible Interface: threading and multiprocessing ... 602
31.5 ... Cooperative Multitasking ... 613
31.6 ... Conclusion: Which Interface Is the Right One? ... 629
32 ... Data Storage ... 631
32.1 ... XML ... 631
32.2 ... Databases ... 643
32.3 ... Compressed Files and Archives ... 661
32.4 ... Serializing Instances: pickle ... 662
32.5 ... The JSON Data Exchange Format: json ... 665
32.6 ... The CSV Table Format: csv ... 667
33 ... Network Communication ... 673
33.1 ... Socket API ... 674
33.2 ... XML-RPC ... 690
34 ... Accessing Resources on the Internet ... 701
34.1 ... Protocols ... 701
34.2 ... Solutions ... 702
34.3 ... The Easy Way: requests ... 703
34.4 ... URLs: urllib ... 705
34.5 ... FTP: ftplib ... 713
35 ... Email ... 721
35.1 ... SMTP: smtplib ... 721
35.2 ... POP3: poplib ... 724
35.3 ... IMAP4: imaplib ... 728
35.4 ... Creating Complex Emails: email ... 734
36 ... Debugging and Quality Assurance ... 739
36.1 ... The Debugger ... 739
36.2 ... Automated Testing ... 741
36.3 ... Analyzing the Runtime Performance ... 749
37 ... Documentation ... 759
37.1 ... Docstrings ... 759
37.2 ... Automatically Generated Documentation: pydoc ... 761
PART V ... Advanced Topics ... 763
38 ... Distributing Python Projects ... 765
38.1 ... A History of Distributions in Python ... 765
38.2 ... Creating Distributions: setuptools ... 767
38.3 ... Creating EXE files: cx_Freeze ... 775
38.4 ... Package Manager ... 776
38.5 ... Localizing Programs: gettext ... 781
39 ... Virtual Environments ... 785
39.1 ... Using Virtual Environments: venv ... 786
39.2 ... Virtual Environments in Anaconda ... 787
40 ... Alternative Interpreters and Compilers ... 789
40.1 ... Just-in-Time Compilation: PyPy ... 789
40.2 ... Numba ... 790
40.3 ... Connecting to C and C++: Cython ... 793
40.4 ... The Interactive Python Shell: IPython ... 799
41 ... Graphical User Interfaces ... 805
41.1 ... Toolkits ... 805
41.2 ... Introduction to tkinter ... 807
41.3 ... Introduction to PySide6 ... 850
41.4 ... Signals and Slots ... 859
41.5 ... Important Widgets ... 861
41.6 ... Drawing Functionality ... 868
41.7 ... Model-View Architecture ... 879
42 ... Python as a Server-Side Programming Language on the Web: An Introduction to Django ... 893
42.1 ... Concepts and Features of Django ... 894
42.2 ... Installing Django ... 895
42.3 ... Creating a New Django Project ... 896
42.4 ... Creating an Application ... 900
43 ... Scientific Computing and Data Science ... 935
43.1 ... Installation ... 936
43.2 ... The Model Program ... 936
43.3 ... Overview of the numpy and scipy Modules ... 944
43.4 ... An Introduction to Data Analysis with pandas ... 953
44 ... Inside Knowledge ... 969
44.1 ... Opening URLs in the Default Browser: webbrowser ... 969
44.2 ... Interpreting Binary Data: struct ... 969
44.3 ... Hidden Password Entry ... 971
44.4 ... Command Line Interpreter ... 972
44.5 ... File Interface for Strings: io.StringIO ... 975
44.6 ... Generators as Consumers ... 976
44.7 ... Copying Instances: copy ... 981
44.8 ... Image Processing: Pillow ... 984
45 ... From Python 2 to Python 3 ... 993
45.1 ... The Main Differences ... 996
45.2 ... Automatic Conversion ... 1001
... Appendices ... 1005
A ... Appendix ... 1005
B ... The Authors ... 1017
... Index ... 1019
1997-2024 DolnySlask.com Agencja Internetowa