Use Python’s breakpoint() function to easily step through your code.
The breakpoint() function was added in Python 3.7 and is part of Python’s built-in functions.
Using breakpoint() is as simple as adding it to your script and running the script.
Here is a simple example using flask.
from flask import Flask
app = Flask(__name__)
return "Hello, breakpoint()!"
After starting the flask application, your terminal will be in a
pdb instance and you can start debugging. Use the
continue command to break out of the debugger and let the code continue executing. Use
next to step to the next line of code.
Tips for creating and using virtual environments in Python 3.
Create a virtual environment
Create a virtual environment with the current Python3 version.
python3 -m venv <directory>
This will create a virtual environment for the given directory.
python3 -m venv venv
Activate a virtual environment
If you created a virtual environment from the Create a virtual environment snippet, you can activate a virtual environment for the created virtual environment directory.
Deactivate a virtual environment
Use the deactivate command to exit the virtual environment.
Over the last year I have spent a good amount of time working with multiple WooCommerce powered websites. As the application becomes more complex, I am finding myself digging deeper into WooCommerce to find out how (or why) something works. I received a feature request that would require finding all orders for a product.
Continue reading “Get All Orders For A Product In WooCommerce”
Laravel does an incredible job helping developers break their code into smaller parts, which reduces code clutter and makes the code easier to read. I recently discovered how to create a custom form request for handling validation during a form submission.
Continue reading “Creating A Custom Form Request In Laravel”
During the process of learning Laravel, I taken up the habit of creating many test applications for new features and ideas. With each new Laravel install, I find myself having to take the time to set up the same thing in each application. This process is becoming tedious as I have to dig through the documentation every time. I decided to document this process to save me some time with each new Laravel install.
Continue reading “What To Do With A New Laravel Project”
I came across an issue when running unit tests in Laravel where my unit tests where altering my local SQLite database. I discovered the issue was due to the sharing of
Continue reading “Using In-Memory SQLite Database During Unit Tests In Laravel”
.env files. It turns out the solution is as simple as adding a single environment variable to your