python-basics

Python fundamentals for beginners: variables, data types, operators, control flow, and functions, the core syntax every Python program is built on.

Python: Operator Overloading and Custom Object Behavior

Learn Python operator overloading with __add__, __sub__, __mul__, __eq__, and reverse operators. Build a Vector class that supports arithmetic, comparison, and string operations using magic methods. “Simple things should be simple, complex things should be possible.” Alan Kay, ACM Queue Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Intermediate | Reading Time: 11 minutes Writing v1.add(v2) feels clunky when you could just write v1 + v2. Python operator overloading lets you decide what +, -, *, ==, ... Read More

Python: Constructors __init__ & Instance Variables

Every object in your program has a birth moment, and __init__ is where it happens. Get that moment right and the whole class can trust its own data; get it wrong and the bug surfaces three files away. This guide covers the Python init constructor patterns that matter: defaults, validation, factory methods, and the mutable default trap. “Beware of bugs in the above code; I have only proved it correct, not tried it.” Donald Knuth, 1977 memo Last Updated: July ... Read More

Python: 20 Most Common Error Messages, What They Mean & How to Fix

These are the 20 Python common errors you hit most, each explained with its exact error text, what causes it, and how to fix it. A scannable reference for every Python developer. “The most effective debugging tool is still careful thought, coupled with judiciously placed print statements.” Brian Kernighan Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Beginner | Reading Time: 20 minutes Here is the good news about Python error messages: they repeat. Every Python developer ... Read More