Below you will find pages that utilize the taxonomy term “Python”
Python And The 'src-vs-flat' Layout Debate
I recently needed to setup a new Python project and in the course of doing so, learned about uv1 , “an extremely fast Python package and project manager”. uv is great. It is easy to install (just a single executable!), and it takes care of all the essential elements of a Python project. Unfortunately, I immediately came across one major problem–uv uses the wrong default for project layouts.
This is the default layout of a project created by uv:
Posts of the Week 11/06/20
https://rootsofprogress.org/immunization-from-inoculation-to-rna-vaccines
When you get your covid shot (probably in 2021), take a moment to think back on the 300 years of progress that got us to this point.
https://github.com/wbolster/emacs-python-black
This is an Emacs package to make it easy to reformat Python code using black, the uncompromising Python code formatter.
Unit tests and system clock
It took me way to long to learn this. Your code (and their unit tests) should inject the system clock as a dependency.
An example, let’s say you have a service that writes a record to the database with the system clock.
public void save(String userName) {
long currentTimeMs = System.currentTimeMillis();
User user = User.builder()
.name(userName)
.updateTimeMs(currentTimeMs);
database.save(user);
}
How would you test this? You can inject a mock database instance and use it to verify that it got a User object. Great! You can verify the username is as expected. How do you verify that tricky business rule that updateTimeMS is the “current time”?