Python Error Handling with try and except
A practical guide to error handling in Python — catching specific exceptions, the else and finally clauses, raising and re-raising, custom exception types, and habits that lead to robust code.
143 posts · page 3 of 3
A practical guide to error handling in Python — catching specific exceptions, the else and finally clauses, raising and re-raising, custom exception types, and habits that lead to robust code.
A complete guide to Python f-strings — basic interpolation, format specifiers for numbers and dates, alignment and padding, debug syntax, and when to choose other formatting methods.
Understand Python generators from the ground up — how yield turns a function into an iterator, lazy evaluation, generator expressions, and when generators beat lists.
Go beyond the basics of Python list comprehensions — filtering, nested loops, conditional expressions, dict and set comprehensions, and when a plain for loop is the better choice.
A practical introduction to Python type hints — basic syntax, common collection types, Optional and Union, type-checking with mypy, and how hints improve code without changing runtime behaviour.
Stop polluting your system Python — a practical guide to virtual environments with venv, activating and deactivating them, requirements.txt, and a quick look at modern alternatives.
Learn LangChain by building real components in Python: prompt templates, chains, tool calling, and memory. Practical patterns you can ship today.
A working tour of the OpenAI Python SDK: chat completions, streaming, structured output, embeddings, tool calls, and production-grade error handling.
A practical introduction to Python asyncio: the event loop, async/await, asyncio.run, gather, create_task, and when to pick async over threads.
A practical introduction to Python regex with the re module: match, search, findall, sub, groups, named groups, raw strings, and compiling patterns for speed.
Understand the Python GIL and pick the right concurrency tool: when threads help with I/O, when processes help with CPU, and how to use concurrent.futures.
A practical introduction to Django — its newsroom origins, the batteries it ships with (ORM, admin, auth, templates), and when to pick it over FastAPI or Flask.
A practical guide to async path operations and Depends() in FastAPI — when async actually helps, per-request DB sessions, auth dependencies, and how sub-dependencies compose.
A practical guide to FastAPI with SQLAlchemy 2.0 — typed models with Mapped and mapped_column, sessionmaker, get_db dependency, CRUD endpoints, and where Alembic fits.
A practical guide to FastAPI routing and Pydantic v2 — path operations, path/query/body parameters, model validation, response_model, and response_model_exclude_unset.
Why splitting matters, how to use train_test_split with stratification, and the metrics that actually matter — accuracy, precision, recall, F1, confusion matrices, and ROC-AUC.
A practical guide to combining and summarising DataFrames — groupby with named aggregations, multi-column aggregates, the four merge styles, and stacking with concat.
Install, pin, and publish — a practical tour of pip, PEP 621 pyproject.toml, and building a tiny library you can share on TestPyPI.
Isolate your Python projects the right way — using the built-in venv module, the new uv tool, and a clear mental model for when to use pipx instead.
A clear introduction to FastAPI — ASGI and Starlette, Pydantic-driven validation, automatic OpenAPI docs, async support, and how it compares to Flask and Django.
A practical guide to the daily DataFrame moves — read_csv and read_json, head and info, column selection, loc vs iloc, boolean filtering, sorting, and value_counts.
A clear introduction to pandas — what DataFrames and Series are, why analysts and ML engineers live in it, how to install it, and a tiny first end-to-end example.
A practical introduction to Python classes — defining a class, __init__ and self, instance vs class attributes, methods, __repr__, and a first look at inheritance.
A practical guide to Python iterators and generators — the iterator protocol, yield, generator expressions, memory benefits, and how to model infinite sequences.
A practical guide to Python lambda functions — syntax, use with sorted, map, and filter, common patterns, and the situations where a named def is the clearer choice.
A practical introduction to pytest — installation, test discovery, the assert statement, parametrize, fixtures, and the command-line flags you will use every day.
A step-by-step setup guide for Python 3 on Windows, macOS, and Linux. Install the interpreter, set up VS Code, and write a working Python program in under ten minutes.
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.
An overview of every built-in data type in Python — int, float, str, bool, list, tuple, dict, set, and None — with examples and guidance on when to use each.
A practical guide to Python function arguments — defaults, keyword arguments, *args, **kwargs, positional-only and keyword-only parameters, and the mutable default gotcha.
A complete beginner's guide to Python dictionaries — creation, access, mutation, iteration, the essential methods, and the patterns that appear in nearly every real Python program.
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 complete beginner's guide to Python lists — creation, indexing, slicing, mutation, the essential methods, iteration patterns, and a first look at list comprehensions.
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 practical guide to integers, floats, arithmetic operators, operator precedence, the math module, and the floating-point gotchas every Python beginner should know.
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.
Learn how Python sets store unique values, the operations they support — union, intersection, difference — and when to choose a set over a list or dictionary.
A thorough introduction to Python strings — creation, escape sequences, indexing, slicing, the essential methods, f-strings, and why strings are immutable.
Understand Python's syntax rules, the role of indentation, statements, comments, and the most common syntax errors that trip up new developers.
A practical guide to Python tuples — creation, the single-element gotcha, packing and unpacking, methods, and when to choose a tuple over a list.
A practical guide to converting between Python types — int, float, str, bool, list, tuple, set, dict — when conversions fail, and the common pitfalls to avoid.
Learn how Python variables work, the rules and conventions for naming them, how dynamic typing changes the rules you may know from other languages, and the naming mistakes to avoid.
A clear, professional introduction to Python — what it is, how it works, why it dominates modern software development, and what you can build with it as a beginner.
A clear guide to Python while loops — condition-driven iteration, break and continue, the else clause, infinite loops, and patterns for safe, terminating code.