Python Projects Up to Date

Keeping Python Projects Up to Date

I had the experience of upgrading Python in the projects from 3.8 to 3.12 in one step, and I realized that keeping the Python versions up to date is just as critical as keeping the dependencies up to date. Maintenance should not be a separate task, it should be part of all the other tasks. If you can check and update package versions in a timely manner, you don’t have to tell anyone that it’s going to hold up your business in the future. ...

March 30, 2025 · 5 min

Better Enumerations in Python

When dealing with more than one language, we look for similar approaches across languages. In Rust, there’s a keyword called enum to define and use enumerations. It’s easy to use, let’s look at this example from the official document: enum IpAddrKind { V4, V6, } struct IpAddr { kind: IpAddrKind, address: String, } let home = IpAddr { kind: IpAddrKind::V4, address: String::from("127.0.0.1"), }; let loopback = IpAddr { kind: IpAddrKind::V6, address: String::from("::1"), }; If we want to write this code in Python, we can define two classes and two variables simply. Let’s start with a simple alternative first: ...

December 8, 2024 · 5 min

Syntax Errors in Logical Operators

Python favours letters and meaningful keywords for the logical operators, and all of them return a value depending on the conditions: not: The opposite of a condition, the reverse of the logical state of its operand. If the condition is True, it returns False, or vice versa. and: It needs to compare two operands, It returns True if both operands are True. or: It’s similar to and, but it returns True if at least one of the operands is True. ...

November 29, 2024 · 3 min

String quotes in PEP8

I use PEP8 in my Python projects except for a few rules. I think ‘single-quote’ and “double-quote” characters should NOT be the same. It could be better if these two characters had different counterparts in the Python language parser system. So we could use one of them for the template-strings (or f-strings). It doesn’t provide readability, causes inconsistency instead. Until now, I used string-quotes for the variable definitions and double-quotes for the visible texts. But now, I plan to use always double-quote as in many other programming languages. ...

January 12, 2019 · 1 min