Comparison and Logical Operators in Python
A complete guide to Python's comparison and logical operators — equality vs identity, chained comparisons, short-circuit evaluation, and common pitfalls.
10 posts.
A complete guide to Python's comparison and logical operators — equality vs identity, chained comparisons, short-circuit evaluation, and common pitfalls.
A practical guide to Python conditionals — if, elif, else, truthiness, conditional expressions, and the patterns that keep branching logic clean and readable.
A practical guide to Python function arguments — defaults, keyword arguments, *args, **kwargs, positional-only and keyword-only parameters, and the mutable default gotcha.
A practical guide to Python exception handling — try, except, else, finally, raising and re-raising, custom exceptions, and the habits that make error handling helpful.
A practical guide to file I/O in Python — open modes, the with statement, reading and writing text and binary, working with paths, and handling common errors.
A practical guide to Python for loops — iterating over sequences, the range function, enumerate and zip, nested loops, and the idiomatic patterns you will use every day.
A practical guide to Python functions — defining with def, returning values, arguments and parameters, docstrings, and the habits that make functions worth reusing.
A practical guide to Python modules and imports — writing your own modules, import forms, packages, the if __name__ == '__main__' idiom, and avoiding common pitfalls.
A clear guide to Python variable scope — local, enclosing, global, and built-in names, the LEGB rule, and when to reach for the global and nonlocal keywords.
A clear guide to Python while loops — condition-driven iteration, break and continue, the else clause, infinite loops, and patterns for safe, terminating code.