Cover....-1
Half Title....2
Title Page....4
Copyright Page....5
Dedication....6
Contents....8
Author....12
Preface....14
Chapter 1. The Absolute Bare Minimum....16
1.1 Python and IDEs....16
1.2 IDLE....17
1.3 Variables....18
1.4 Important Data Types....18
1.5 Basic Arithmetic....19
1.6 Comparisons....21
1.7 Booleans....21
1.8 Lists....22
1.9 Strings....23
1.10 Comments....24
1.11 Statement Types....24
1.11.1 Assignment Statements....25
1.11.2 Print "Statements"....25
1.11.3 If Statements....26
1.11.4 While Loops....26
1.11.5 For Loops....27
1.11.6 Import Statements....28
1.12 Input from the User....29
1.13 Functions....29
1.14 Syntax....30
1.15 Order of Execution....31
1.16 Summary....31
1.17 Wait, That's It?....32
Chapter 2. Better Tools....34
2.1 Object Notation....34
2.2 Lists....35
2.3 Tuples....37
2.4 Sets....38
2.5 Dictionaries....40
2.6 String Methods....42
2.7 Loops for Objects....43
2.7.1 Looping over Lists....43
2.7.2 Looping over Sets....44
2.7.3 Looping over Dictionaries....44
2.8 Handing Exceptions....45
2.9 Type Conversions....48
2.10 Scope....49
2.11 File I/O....51
2.12 Pickling....53
Chapter 3. Classes....54
3.1 Classes and Inheritance....54
3.2 Constructors and Self....56
3.3 Subclasses....59
3.4 Printing Objects....60
3.5 Comparing Objects....62
3.6 Bindings....63
3.7 Shallow and Deep Copies....65
Chapter 4. Getting Fancy....68
4.1 Statements....68
4.2 Identifiers....71
4.3 Type Hints....72
4.4 Numbers....73
4.5 Strings....74
4.6 F-Strings....75
4.7 Bit Operations....76
4.8 List Comprehensions....77
4.9 Iterators....78
4.10 Generators....81
4.11 Parameters and Arguments....83
4.12 Functional Programming....84
Chapter 5. Testing....88
5.1 Philosophy....89
5.2 Doctest....90
5.3 Unit Testing....92
5.4 Unit Test Example....95
5.5 Test Suites....96
Chapter 6. Graphical User Interfaces....98
6.1 Dialogs....98
6.2 Tkinter....99
6.3 Creating Widgets....100
6.4 Putting Widgets into the GUI....102
6.5 Tkinter Example....104
Afterword....106
Appendix A. String Methods....108
Appendix B. Numerical Functions....112
Appendix C. Statistics....116
Appendix D. Functions on Iterables....118
Appendix E. Operating System Commands....120
Appendix F. Unit Test Methods....122
Index....124
Are you a programmer who wants to get started quickly in a new language? This book is for you.
Are you a novice who wants to learn to program? This book is not for you.
Are you a Python programmer who needs encyclopaedic information? This book is not for you.
Like any mainstream language, Python has loops, if statements, assignment statements, functions, etc. I’ll show you what these look like in Python. I won’t waste your time telling you what they’re good for.
Python has features you may not be familiar with--iterators, list comprehensions, maybe even dictionaries. I’ll spend more time on these.
I’ll cover some of the library functions I found most immediately useful, and tell you where to find more.
In short, this book will help you hit the ground running. Next week, you’ll be ready to buy that Python encyclopaedia.