Today I became aware of the existence of the builtin Python module fractions. The fractions module handles rational number arithmetic. Here's a simple example using the Fraction class to covert a decimal into a Fraction with the numerator and denominator reduced to the lowest terms. My ...
Python
Counting Pixels by Color in Python with Pillow (a PIL fork)
I'm a maker and love creating 8-bit art, mostly with wood. I have a new project in the works where I need an exact count of each pixel per a color. I started to manually count them before I stopped myself and thought, why don't I just write a script to automate this!? ...
Tinkering Around with Adafruit’s PyBadge LC
I recently purchased an Adafruit PyBadge LC. and I've had a lot fun tinkering around with it. There are three boards in this family of boards from Adafruit: PyBadge LC (the one I have)PyBadgePyGamer The PyBadge LC is the cheapest of the bunch, hence the LC for low cost. For more details on the ...
I made a Sphere-O-Bot (An EggBot Mod)
As Easter approaches, I thought building a Sphere-O-Bot (EggBot) would be a fun a STEM related project for the season. I 3D printed the parts for the Sphere-O-Bot, a variant of the original EggBot by Evil Mad Science, and purchased the hardware kit from JJ Robots. Printing and assembling the ...
Avoid using mutable values as default parameter values in Python (Today I Learned)
Today I learned something interesting about the way Python functions behave with default parameter values: avoid using mutable objects such as lists as default values for function parameters. What's the problem? Default parameter values are evaluated when function is evaluated. Which means ...
How to watermark images with Python and Pillow (PIL)
I am a DIY blogger, and the most tedious part of the job is editing the images. I am constantly repeating the following steps: Resize the imageAdd a text watermarkCompress the image I wanted to automate the process. There are good solutions out there for automating image manipulation, but it ...