If you’re new to Python, it can be tough to understand when, where, and how to use all its language features. This friendly guide shows you how the Python ecosystem fits together, and grounds you in the skills you need to continue your journey to being a software developer.
Inside The Well-Grounded Python Developer you will discover:
• Building modules of functionality
• Creating a well-constructed web server application
• Integrating database access into your Python applications
• Refactor and decoupling systems to help scale them
• How to think about the big picture of your application
The Well-Grounded Python Developer builds on Python skills you’ve learned in isolation and shows you how to unify them into a meaningful whole. It helps you understand the dizzying array of libraries and teaches important concepts, like modular construction, APIs, and the design of a basic web server. As you work through this practical guide, you’ll discover how all the bits of Python link up as you build and modify a typical web server application—the kind of web app that’s in high demand by modern businesses.
About the technology
As a new programmer, you’re happy just to see your code run. A professional developer, on the other hand, needs to create software that runs reliably. It must be fast, maintainable, scalable, secure, well designed and documented, easy for others to update, and quick to ship. This book teaches you the skills you need to go from Python programmer to Python developer.
About the book
The Well-Grounded Python Developer shows you why Python, the world’s most popular programming language, is a fantastic tool for professional development. It guides you through the most important skills, like how to name variables, functions, and classes, how to identify and write a good API, and how to use objects. You’ll also learn how to deal with inevitable failures, how to make software that connects to the internet, core security practices, and many other professional-grade techniques.
What's inside
• Create a web application
• Connect to a database
• Design programs to handle big tasks
About the reader
For experienced beginners who want to learn professional-level skills.
About the author
Doug Farrell has been a professional developer since 1983, and has worked with Python for over 20 years.
Author(s): Doug Farrell
Edition: 1
Publisher: Manning
Year: 2023
Language: English
Commentary: Publisher's PDF
Pages: 296
City: Shelter Island, NY
Tags: Databases; Debugging; Python; Web Applications; Relational Databases; Logging; Maintanability; Best Practices; Flask; Object-Oriented Programming; SQLite; SQLAlchemy; Unit Testing; Web Servers; Integration Testing; Regression Testing; Testing; Performance Testing; Performance; Persistence; Gunicorn; Version Control Systems; Polymorphism; Exception Handling; Acceptance Testing; Functional Testing; Naming; Authentication; Accessibility Testing; APIs; UUID; End-to-end Testing
The Well-Grounded Python Developer
contents
foreword
preface
acknowledgments
about this book
Who should read this book
How this book is organized: A road map
About the code
liveBook discussion forum
about the author
about the cover illustration
brief contents
1 Becoming a Pythonista
1.1 Commitment to learning
1.2 Reaching goals
1.2.1 Thinking like a developer
1.2.2 Building applications
1.3 Using Python
1.3.1 Programming paradigms
1.3.2 Creating maintainable code
1.3.3 Performance
1.3.4 The language community
1.3.5 Developer tooling
1.4 Selecting which Python version to use
1.5 Closing thoughts
Summary
Part 1 Groundwork
2 That’s a good name
2.1 Names
2.1.1 Naming things
2.1.2 Naming experiment
2.2 Namespaces
2.3 Python namespaces
2.3.1 Built-ins level
2.3.2 Module level
2.3.3 Function level
2.3.4 Namespace scope
2.3.5 Namespace experiment
Summary
3 The API: Let’s talk
3.1 Starting a conversation
3.1.1 A contract between pieces of code
3.1.2 What’s passed as input
3.1.3 What’s expected as output
3.2 Function API
3.2.1 Naming
3.2.2 Parameters
3.2.3 Return value
3.2.4 Single responsibility
3.2.5 Function length
3.2.6 Idempotence
3.2.7 Side effects
3.3 Documentation
3.4 Closing thoughts
Summary
4 The object of conversation
4.1 Object-oriented programming (OOP)
4.1.1 Class definition
4.1.2 Drawing with class
4.1.3 Inheritance
4.1.4 Polymorphism
4.1.5 Composition
4.2 Closing thoughts
Summary
5 Exceptional events
5.1 Exceptions
5.2 Handling exceptions
5.2.1 Handling an exception if the code can do something about it
5.2.2 Allowing exceptions to flow upward in your programs
5.2.3 Informing the user
5.2.4 Never silence an exception
5.3 Raising an exception
5.4 Creating your own exceptions
5.5 Closing thoughts
Summary
Part 2 Fieldwork
6 Sharing with the internet
6.1 Sharing your work
6.1.1 Web application advantages
6.1.2 Web application challenges
6.2 Servers
6.2.1 Request-response model
6.3 Web servers
6.4 Flask
6.4.1 Why Flask?
6.4.2 Your first web server
6.4.3 Serving content
6.4.4 More Jinja2 features
6.5 Running the web server
6.5.1 Gunicorn
6.5.2 Commercial hosting
6.6 Closing thoughts
Summary
7 Doing it with style
7.1 Application styling
7.1.1 Creating appealing styles
7.1.2 Styling consistency
7.1.3 Normalizing styles
7.1.4 Responsive design
7.2 Integrating Bootstrap
7.2.1 The previous example, now with Bootstrap
7.3 Helping MyBlog grow
7.3.1 The Flask app instance
7.4 Namespaces
7.4.1 Flask Blueprints
7.4.2 Add Blueprints to MyBlog
7.4.3 Create the about page
7.4.4 Refactored app instance
7.5 Navigation
7.5.1 Creating navigation information
7.5.2 Displaying navigation information
7.5.3 MyBlog’s current look
7.6 Application configuration
7.6.1 Configuration files
7.6.2 Private information
7.7 Flask Debug Toolbar
7.7.1 FlaskDynaConf
7.8 Logging information
7.8.1 Configuration
7.9 Adding a favicon
7.10 Closing thoughts
Summary
8 Do I know you? Authentication
8.1 The HTTP protocol is stateless
8.1.1 Sessions
8.2 Remembering someone
8.2.1 Authentication
8.2.2 Logging in
8.3 News flash
8.3.1 Improving the login form
8.4 Making new friends
8.4.1 Auth Blueprint
8.4.2 New user form
8.4.3 Oh yeah: logging out
8.5 What’s next
Summary
9 What can you do? Authorization
9.1 Login/logout navigation
9.2 Confirming new friends
9.2.1 Sending email
9.3 Resetting passwords
9.4 User profiles
9.5 Security
9.5.1 Protecting routes
9.6 User authorization roles
9.6.1 Creating the roles
9.6.2 Authorizing routes
9.7 Protecting forms
9.8 Closing thoughts
Summary
10 Persistence is good: Databases
10.1 The other half
10.1.1 Maintaining information over time
10.2 Accessing data
10.3 Database systems
10.3.1 Tables
10.3.2 Relationships
10.3.3 Transaction database
10.3.4 Structured query language: SQL
10.4 SQLite as the database
10.5 SQLAlchemy
10.5.1 Benefits
10.6 Modeling the database
10.6.1 Defining the classes
10.7 Creating and using the database
10.7.1 Adding data
10.7.2 Using the data
10.8 Closing thoughts
Summary
11 I’ve got something to say
11.1 MyBlog posts
11.1.1 Modeling the database
11.2 Change of direction
11.3 Content Blueprint
11.4 Displaying and creating posts
11.4.1 Display handler
11.4.2 Display template
11.5 Creating posts
11.5.1 Creation handler
11.5.2 Creation form
11.5.3 Creation template
11.6 Displaying and editing a post
11.6.1 Display handler
11.6.2 Display template
11.6.3 Update handler
11.6.4 Update form
11.6.5 Update template
11.7 Content to comment hierarchy
11.7.1 Modifying the post class
11.7.2 Display handler
11.7.3 Display template
11.8 Creating comments
11.8.1 Creation template
11.8.2 Creation form
11.8.3 Creation handler
11.9 Notifying users
11.10 Handling site errors
11.11 Closing thoughts
Summary
12 Are we there yet?
12.1 Testing
12.1.1 Unit testing
12.1.2 Functional testing
12.1.3 End-to-end testing
12.1.4 Integration testing
12.1.5 Load testing
12.1.6 Performance testing
12.1.7 Regression testing
12.1.8 Accessibility testing
12.1.9 Acceptance testing
12.2 Debugging
12.2.1 Reproducing bugs
12.2.2 Breakpoints
12.2.3 Logging
12.2.4 Bad results
12.2.5 Process of elimination
12.2.6 Rubber-ducking the problem
12.3 Tools
12.3.1 Source control
12.3.2 Optimization
12.3.3 Containers
12.3.4 Databases
12.3.5 Languages
12.4 OS environments
12.5 Cloud computing
12.6 Networking
12.7 Collaboration
12.8 Closing thoughts
Summary
appendix Your development environment
A.1 Installing Python
A.1.1 Windows
A.1.2 Mac
A.1.3 Linux
A.2 Python virtual environment
A.2.1 Windows
A.2.2 Mac and Linux
A.3 Setting up Visual Studio Code
A.3.1 Installing Visual Studio Code
A.3.2 Installing the Python extension
A.3.3 Other useful extensions
A.3.4 Starting from the command line
A.3.5 Starting a project
A.4 Some advice
index
Symbols
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
R
S
T
U
V
W
X
The Well-Grounded Python Developer - back