#dailypythonista — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #dailypythonista, aggregated by home.social.
-
Has anyone here read „A Philosophy of Software Design” by John Ousterhost? If so - was it worth the time spent? If not - why?
Decided to ask here because I definitely need to cut off on my reading list, and adding there every book I came across with no real recommendation is definitely not the way to go here 😅
#DailyPythonista #programming #askfedi #askmastodon #books
https://www.goodreads.com/book/show/39996759-a-philosophy-of-software-design
-
I kept forgetting how to assert exception messages in PyTest, so I finally checked the docs.
Here’s a reference snippet 🐍
#TIL #DailyPythonista #PyTest #TDD #Python #programming
https://borutzki.github.io/2026/03/30/how-to-assert-exception-message-in-pytest.html
-
Have you ever seen the typing.overload decorator in the wild and wondered what it's actually for?
I wrote a short blog post explaining the problem it solves and how to use it in practice. 🐍
https://borutzki.github.io/2026/02/07/how-to-use-overloaded-signatures-in-python.html
-
Debugger is fun and stuff but sometimes it's just faster to dump Django ORM data to a JSON, skim through it, apply fixes and forget about the topic.
Here's how to do that programmatically, e.g. during TestCase execution.
#Django #Python #programming #DailyPythonista #TDD
https://borutzki.github.io/2026/01/25/how-to-dump-django-orm-data-to-json-while-debugging.html
-
What if I told you that the following way of taking the second object from a Django `QuerySet` might be unreliable and can lead to non-deterministic failures under some circumstances?
And if you think it's a bad idea whatsoever - can you explain why?
Take a look on my recent blog post for more details: https://borutzki.github.io/2026/01/19/why-using-n-on-a-django-queryset-can-be-unsafe.html
-
Ever wondered how to parametrize exception testing in PyTest?
Try this:
https://borutzki.github.io/2026/01/15/how-to-parametrize-exception-testing-in-pytest.html#DailyPythonista #python #programming #Pytest #TDD #unittest
-
Out of nowhere I decided to describe briefly my approach to reuse model_validator (and any other validator) across multiple #Pydantic models.
Code snippet from image should do the job, full context is in the linked blog post.
-
Ever needed to check for root / admin privileges to make sure your Python script can work correctly?
In my last blog post, I provide you with approach for Linux, macOS and Windows to get this stuff done.
Happy hacking 🐍
#DailyPythonista #Python #programming
https://borutzki.github.io/2025/10/16/how-to-check-whether-python-script-has-elevated-privileges.html -
Writing a technical article - even very subjective one - is quite a lot of work, if one wants to cover the topic well and at the same point not write a book on it in one go.
Just wanted to say that after a writing session.
Used a bunch of guard clauses (https://refactoring.guru/pl/replace-nested-conditional-with-guard-clauses) in text to state what the article is NOT about, to not waste my readers' computing power on reading something they're not interested in 😅
Still, it's work in progress. Until next time!
#DailyPythonista -
Finally, started working on a separate blog dedicated to technical stuff like #Python, #Django, #Pydantic, #GitLab, #Docker, #RobotFramework and so on.
In this first post I introduce myself and the purpose of the blog, then proceed to a bunch of quick examples of printing "hello world" in Python.
Even if you're not interested - come and see how to add padding to printed string in Python 🐍
-
Finished reading "Working Effectively with Legacy Code" by Michael Feathers.
Even though some information from the book was useful, I feel like techniques proposed there don't stand up to current test frameworks with mocking systems.
Hence, most of the tips are not relevant in #Python world.
I liked though was the angle author took on encapsulation and component boundaries, though.
Have you read the book? What did you like (or not) about it?
-
If you want to hear me talking about bad #RobotFramework practices and how to mitigate their outcomes, sign up for #Wrobocon conference happening October 23rd 🤖
Image below comes from the official announcement from LinkedIn, hopefully no one will get angry for posting it here 😬
Conference web page: https://wrobocon.eu/
LinkedIn announcement: https://www.linkedin.com/posts/wrobocon2025_speaker-announcement-python-activity-7363941414872756224-6VN1 -
During my „side-project” I noticed that Gherkin style is great not only for describing behaviour of software. It’s also great for describing any kind of behaviour 🤖
Let’s make fun of my consistency of posting Python stuff here on mastodon:
Given I have an idea for new Python-related toot
And I don't write it down
When I want to write the toot
Then I don't remember what was the ideaNote that this also enables possibilities to "debug" and "explore" that behaviour further.
-
#TIL in Python, combination of `cache` and `staticmethod` decorators might cause bug in some cases.
It is caused by the fact that `cache` overrides `staticmethod` which no longer is a static method. Hence, it fails when called from class instance because it sees `self` as an unexpected argument - and TypeError is thrown.
See thiss StackOverflow thread for further reference.
https://stackoverflow.com/questions/76403155/does-it-make-sense-to-decorate-a-staticmethod-with-an-lru-cache/76403292#76403292 -
Meanwhile, in #RobotFramework universe, a new tool emerges that allows for setting up test dependencies.
So, for example if test X fails, then test Y does not make sense, hence is not executed.
It might be actually useful in many end-to-end scenarios, where the rule of keeping tests independent causes either a lot of repetition of costly operations.
#Python #DailyPythonista #TestAutomation
https://pypi.org/project/robotframework-dependencysolver/ -
If you ever ask why it’s worth updating #Python dependencies from time to time, #Pydantic serves as a nice example with the performance boost introduced. I actually could see it, given the complexity of models I deal with on a daily basis.
> Recent memory usage optimizations are most relevant for projects with lots of models, particularly those with nested/reused models. In these cases, you can expect a 2-5x reduction in memory usage.
#DailyPythonista
https://pydantic.dev/articles/pydantic-v2-11-release -
#TIL if you have to deal with lengthy tests in #PyTest, you can split them to sub-tests.
There's a library `pytest-subtests` specifically for that. It basically introduces `subTest` functionality from `unittest` built-in to PyTest, so it is becomes possible to neatly structure complicated tests.
Especially useful for end-to-end-like tests that have to perform a bunch of operations in a sequence and validate output of each. 🐍
#DailyPythonista #Python #Programming
https://pypi.org/project/pytest-subtests/ -
Ever heard of #frupidity? Hopefully you've never worked in one (but chances are, you have).
> Enter frupidity, or stupid frugality – the obsessive drive to save money in ways that ultimately cost far more in lost productivity, morale, and sanity. It’s the engineering equivalent of “optimizing” a car by removing the brakes to improve gas mileage.
Great read from @selix 👌
-
Looks like now you can become "Robot Framework Certified Professional" for €240 🤖
Even if you don't plan to do the whole examination, it's worth taking a look on the syllabus. For me, it looks like a singular document that I would point to whenever asked by someone about "how to learn Robot Framework".
What do you think about such certification? Is it worth the price?
#RobotFramework #Python #Programming #DailyPythonista #certification
https://cert.robotframework.org/certificates/RFCP -
What got me thinking today at work was how to test one massive set of transactions in #Django with support of #PyTest. One test is like 400 lines of code (multiple objects created and outputs created, “by design”).
Sounds like a neat challenge to tackle Monday morning.
Maybe anyone here tackled something like this? Tried splitting big test into smaller chunks and testing steps but with shared scope of variables and test database state?
-
@hynek thanks for the article on subclassing!
You had nice prediction - it was on my reading list for many months. Took me 1 big coffee to finish, but was worth it. I feel like I should take one more look to protocols in Python (which I used to use but different project and forgot the thing a bit) 🐍
Definitely one of the best takes on the topic of inheritance in Python.
-
If you use #macOS and have a problem with #Docker not working, take a look on this incident update:
https://www.docker.com/blog/incident-update-docker-desktop-for-mac/ -
Cool thing I found on StackOverflow recently.
I tended to forget how to rename #git branch. Hence, this alias for the operation came in handy:
git config --global alias.rename 'branch -m'
Now, to change the name of a branch, the following can be used (no `<old_name>` needed when renaming current branch):
git rename <old_name> <new_name>
Will have to find something as clean for `git push origin -u <newname>` afterwards, though.
-
For some reason, I support newcomers at work recently.
What I tend to suggest as first tasks to do:
- code cleanups
- adding documentation / type hints
- writing unit testsWhy?
1. It requires reading code and getting familiar with it.
2. When something is unclear for a newcomer, it's a great feedback for more matured devs.
3. Onboarding without getting to the codebase is a nonsense.
4. It introduces newcomer to code delivery process.
5. It's useful. -
Today I learned that class attributes are not resetted between unit tests in #PyTest, so when I change some class attribute in test A, then test B will use such overwritten class attribute.
Seems like "fix" for that is to initialize the class first and then change class attribute on this instance, instead of doing this directly on the class definition.
-
Didn’t have time to write a whole article on why readability matters, so just reduced it to a low-quality meme.
(now going back to continue refactoring some production code to at least barely understand how the new feature I develop can be implemented)
-
Today I started reading „Tidy First?” by Kent Beck. Short book with quick overview of possible non-breaking code cleanups (as opposed to Martin Fowler’s refactoring, I guess). I’m at about ~50% of its length now and can recommend this as something worth the time (given that it may take about 2 hours to read if you don't compulsively take notes during reading as I do).
-
Reading a book about #Docker was the right decision. Not only I’ve re-learned basic stuff. I’ve also learned possibilities I didn’t know were there.
Let’s take filesystem layers for example. Basically, each new instruction in Dockerfile adds a layer to image’s filesystem. And once layer is there, next instructions won’t delete it. They can only add.
Hence, you have to do a cleanup action immediately - or it doesn’t make sense.
Cool. And that’s only a tip of an iceberg 🐳
-
#TIL that #Pydantic can make doing JSON-heavy stuff in #Python much more approachable and comprehensible. Stuff like data validation, modeling and overall handling - I wish I had the time to learn that way earlier.
Someday I want to learn how to connect that with #Django data model. But first, I probably need to learn Django.
But not everything at once. Life is not university, no need to cram everything in one week.
-
I see that there are generally two ends of the #CleanCode spectrum:
1. Damn that, it works!
2. Damn that it works.My take on this dichotomy? It’s better to focus on writing a code that can be easily understood than only to make it work. Computer will do what it’s asked for, but it won’t modify or fix the code itself (unless AI can do that, which I heard recently, may be the case). But it’s nice to understand as a human what is the computer asked for.