ebook img

Python 101: Second Edition PDF

764 Pages·2020·8.955 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Python 101: Second Edition

Python 101 2nd Edition Michael Driscoll This book is for sale at http://leanpub.com/py101 This version was published on 2020-08-29 * * * * * This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process. Lean Publishing is the act of publishing an in- progress ebook using lightweight tools and many iterations to get reader feedback, pivot until you have the right book and build traction once you do. * * * * * © 2020 Michael Driscoll Table of Contents About the Technical Reviewers Ethan Furman Martin Breuss Acknowledgments Introduction Part I - The Basics Part II - Intermediate Materials Part III - Tutorials Part IV - Python Packaging and Distribution Target Audience About the Author Conventions Requirements Book Source Code Reader Feedback Errata Part I - The Python Language Chapter 1 - Installing Python Installing on Windows Installing on Mac Installing on Linux Android / iOS Other Operating Systems Other Python Variants Wrapping Up Chapter 2 - Python Editors What About the REPL? Getting Started with IDLE Getting Started with PyCharm Community Edition Getting Started with Wing Personal Getting Started with Visual Studio Code Wrapping Up Chapter 3 - Documenting Your Code What are Comments? Commenting Out Multiline Comments Learning About docstrings Python’s Style Guide: PEP8 Tools that can help Wrapping Up Review Questions Chapter 4 - Working with Strings Creating Strings String Methods String Formatting Formatting Strings Using %s (printf-style) Formatting Strings Using .format() Formatting Strings with f-strings String Concatenation String Slicing Wrapping Up Review Questions Chapter 5 - Numeric Types Integers Floats Complex Numbers Numeric Operations Augmented Assignment Wrapping Up Review Questions Chapter 6 - Learning About Lists Creating Lists List Methods List Slicing Copying a List Wrapping Up Review Questions Chapter 7 - Learning About Tuples Creating Tuples Working With Tuples Concatenating Tuples Special Case Tuples Wrapping Up Review Questions Chapter 8 - Learning About Dictionaries Creating Dictionaries Accessing Dictionaries Dictionary Methods Modifying Your Dictionary Deleting Items From Your Dictionary Wrapping Up Review Questions Chapter 9 - Learning About Sets Creating a Set Accessing Set Members Changing Items Adding Items Removing Items Clearing or Deleting a Set Set Operations Wrapping Up Review Questions Chapter 10 - Boolean Operations and None The bool() Function What About None? Wrapping Up Review Questions Chapter 11 - Conditional Statements Comparison Operators Creating a Simple Conditional Branching Conditional Statements Nesting Conditionals Logical Operators Special Operators Wrapping Up Review Questions Chapter 12 - Learning About Loops Creating a Loop for Looping Over a String Looping Over a Dictionary Extracting Multiple Values in a Tuple While Looping Using with Loops enumerate Creating a Loop while Breaking Out of a Loop Using continue Loops and the Statement else Nesting Loops Wrapping Up Review Questions Chapter 13 - Python Comprehensions List Comprehensions Nested List Comprehensions Dictionary Comprehensions Set Comprehensions Wrapping Up Review Questions Chapter 14 - Exception Handling The Most Common Exceptions Handling Exceptions Raising Exceptions Examining the Exception Object Using the Statement finally Using the Statement else Wrapping Up Review Questions Chapter 15 - Working with Files The open() Function Reading Files Reading Binary Files Writing Files Seeking Within a File Appending to Files Catching File Exceptions Wrapping Up Review Questions Chapter 16 - Importing Using import Using to Import Specific Bits & Pieces from Using to assign a new name as Importing Everything Wrapping Up Review Questions Chapter 17 - Functions Creating a Function Calling a Function Passing Arguments Type Hinting Your Arguments Passing Keyword Arguments Required and Default Arguments What are and ? *args **kwargs Positional-only Parameters Scope Wrapping Up Review Questions Chapter 18 - Classes Class Creation Figuring Out self Public and Private Methods / Attributes Subclass Creation Polymorphism Making the Class Nicer Wrapping Up Review Questions Part II - Beyond the Basics Chapter 19 - Introspection Using the Function type() Using the Function dir() Getting help() Other Built-in Introspection Tools Wrapping Up Review Questions Chapter 20 - Installing Packages with pip Installing a Package Exploring Command Line Options Installing with requirements.txt Upgrading a Package Checking What’s Installed Uninstalling Packages Alternatives to pip Wrapping Up Review Questions Chapter 21 - Python Virtual Environments Python’s Library venv The Package virtualenv Other Tools Wrapping Up Review Questions Chapter 22 - Type Checking in Python Pros and Cons of Type Hinting Built-in Type Hinting / Variable Annotation Collection Type Hinting Hinting Values That Could be None Type Hinting Functions What To Do When Things Get Complicated Classes Decorators Aliasing Other Type Hints Type Comments Static Type Checking Wrapping Up Review Questions Chapter 23 - Creating Multiple Threads Pros of Using Threads Cons of Using Threads Creating Threads Subclassing Thread Writing Multiple Files with Threads Wrapping Up Review Questions Chapter 24 - Creating Multiple Processes Pros of Using Processes Cons of Using Processes Creating Processes with multiprocessing Subclassing Process Creating a Process Pool Wrapping Up Review Questions Chapter 25 - Launching Subprocesses with Python The Function subprocess.run() The Class subprocess.Popen() The Function subprocess.Popen.communicate() Reading and Writing with and stdin stdout Wrapping Up Review Questions Chapter 26 - Debugging Your Code with pdb Starting in the REPL pdb Starting on the Command Line pdb Stepping Through Code Adding Breakpoints in pdb Creating a Breakpoint with set_trace() Using the built-in Function breakpoint() Getting Help Wrapping Up Review Questions Chapter 27 - Learning About Decorators Creating a Function Creating a Decorator Applying a Decorator with @ Creating a Decorator for Logging Stacking Decorators Passing Arguments to Decorators Using a Class as a Decorator Python’s Built-in Decorators Python Properties Wrapping Up Review Questions Chapter 28 - Assignment Expressions Using Assignment Expressions What You Cannot Do With Assignment Expressions

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.