Book description
You’ve completed a basic Python programming tutorial or finished Al Sweigart’s best selling Automate the Boring Stuff with Python. What’s the next step toward becoming a capable, confident software developer?
Welcome to Beyond the Basic Stuff with Python. More than a mere collection of advanced syntax and masterful tips for writing clean code, you’ll learn how to advance your Python programming skills by using the command line and other professional tools like code formatters, type checkers, linters, and version control. Sweigart takes you through best practices for setting up your development environment, naming variables, and improving readability, then tackles documentation, organization and performance measurement, as well as object-oriented design and the Big-O algorithm analysis commonly used in coding interviews. The skills you learn will boost your ability to program—not just in Python but in any language.
You’ll learn:
•Coding style, and how to use Python’s Black auto-formatting tool for cleaner code
•Common sources of bugs, and how to detect them with static analyzers
•How to structure the files in your code projects with the Cookiecutter template tool
•Functional programming techniques like lambda and higher-order functions
•How to profile the speed of your code with Python’s built-in timeit and cProfile modules
•The computer science behind Big-O algorithm analysis
•How to make your comments and docstrings informative, and how often to write them
•How to create classes in object-oriented programming, and why they’re used to organize code
Toward the end of the book you’ll read a detailed source-code breakdown of two classic command-line games, the Tower of Hanoi (a logic puzzle) and Four-in-a-Row (a two-player tile-dropping game), and a breakdown of how their code follows the book’s best practices. You’ll test your skills by implementing the program yourself.
Of course, no single book can make you a professional software developer. But Beyond the Basic Stuff with Python will get you further down that path and make you a better programmer in the process as you learn to write readable code that’s easy to debug and perfectly Pythonic.
Table of contents
- Acknowledgments
- Introduction
-
Part 1: Getting Started
-
Chapter 1: Dealing with Errors and Asking for Help
- How to Understand Python Error Messages
- Preventing Errors with Linters
-
How to Ask for Programming Help
- Limit Back and Forth by Providing Your Information Upfront
- State Your Question in the Form of an Actual Question
- Ask Your Question on the Appropriate Website
- Summarize Your Question in the Headline
- Explain What You Want the Code to Do
- Include the Full Error Message
- Share Your Complete Code
- Make Your Code Readable with Proper Formatting
- Tell Your Helper What You’ve Already Tried
- Describe Your Setup
- Examples of Asking a Question
- Summary
-
Chapter 2: Environment Setup and the Command Line
- The Filesystem
- Programs and Processes
-
The Command Line
- Opening a Terminal Window
- Running Programs from the Command Line
- Using Command Line Arguments
- Running Python Code from the Command Line with -c
- Running Python Programs from the Command Line
- Running the py.exe Program
- Running Commands from a Python Program
- Minimizing Typing with Tab Completion
- Viewing the Command History
- Working with Common Commands
- Environment Variables and PATH
- Running Python Programs Without the Command Line
- Summary
-
Chapter 1: Dealing with Errors and Asking for Help
-
Part 2: Best Practices, Tools, and Techniques
- Chapter 3: Code Formatting with Black
- Chapter 4: Choosing Understandable Names
- Chapter 5: Finding Code Smells
- Chapter 6: Writing Pythonic Code
-
Chapter 7: Programming Jargon
-
Definitions
- Python the Language and Python the Interpreter
- Garbage Collection
- Literals
- Keywords
- Objects, Values, Instances, and Identities
- Items
- Mutable and Immutable
- Indexes, Keys, and Hashes
- Containers, Sequences, Mapping, and Set Types
- Dunder Methods and Magic Methods
- Modules and Packages
- Callables and First-Class Objects
-
Commonly Confused Terms
- Statements vs. Expressions
- Block vs. Clause vs. Body
- Variable vs. Attribute
- Function vs. Method
- Iterable vs. Iterator
- Syntax vs. Runtime vs. Semantic Errors
- Parameters vs. Arguments
- Type Coercion vs. Type Casting
- Properties vs. Attributes
- Bytecode vs. Machine Code
- Script vs. Program, Scripting Language vs. Programming Language
- Library vs. Framework vs. SDK vs. Engine vs. API
- Summary
- Further Reading
-
Definitions
-
Chapter 8: Common Python Gotchas
- Don’t Add or Delete Items from a List While Looping Over It
- Don’t Copy Mutable Values Without copy.copy() and copy.deepcopy()
- Don’t Use Mutable Values for Default Arguments
- Don’t Build Strings with String Concatenation
- Don’t Expect sort() to Sort Alphabetically
- Don’t Assume Floating-Point Numbers Are Perfectly Accurate
- Don’t Chain Inequality != Operators
- Don’t Forget the Comma in Single-Item Tuples
- Summary
- Chapter 9: Esoteric Python Oddities
- Chapter 10: Writing Effective Functions
- Chapter 11: Comments, Docstrings, and Type Hints
- Chapter 12: Organizing Your Code Projects with Git
- Chapter 13: Measuring Performance and Big O Algorithm Analysis
- Chapter 14: Practice Projects
-
Part 3: Object-Oriented Python
- Chapter 15: Object-Oriented Programming and Classes
- Chapter 16: Object-Oriented Programming and Inheritance
- Chapter 17: Pythonic OOP: Properties and Dunder Methods
- Index
Product information
- Title: Beyond the Basic Stuff with Python
- Author(s):
- Release date: December 2020
- Publisher(s): No Starch Press
- ISBN: 9781593279660
You might also like
book
Serious Python
Sharpen your Python skills as you dive deep into the Python programming language with Serious Python. …
book
Learn Python Programming - Third Edition
Get up and running with Python 3.9 through concise tutorials and practical projects in this fully …
book
Learning Python, 5th Edition
Get a comprehensive, in-depth introduction to the core Python language with this hands-on book. Based on …
book
Dead Simple Python
Dead Simple Python is a thorough introduction to every feature of the Python language for programmers …