Interview Q&A · questions with model answers

Python Developer Interview Questions

Part of the study plan for: Full Stack Engineer · Native AI Engineer · Forward Deployed Engineer (FDE) · Machine Learning Engineer · Data Engineer

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. Most asked What is the late-binding closure gotcha in Python?

    Closures capture variables, not values: lambdas created in a loop all see the variable's final value when called. Fix it by binding the current value as a default argument or using functools.partial.

  2. Most asked What do EAFP and LBYL mean, and which is more Pythonic?

    EAFP ('Easier to Ask Forgiveness than Permission') tries the operation and handles exceptions; LBYL ('Look Before You Leap') checks conditions first. EAFP is generally considered more Pythonic and…

  3. What is free-threaded Python (PEP 703) and how does it change the GIL story?

    Starting with Python 3.13, CPython offers an optional free-threaded build (python3.13t) with the GIL disabled, so threads can run Python bytecode in parallel on multiple cores. In 3.14 the…

  4. What are exception groups and `except*` (Python 3.11)?

    ExceptionGroup bundles multiple unrelated exceptions raised together (e.g., by several concurrent tasks in a TaskGroup), and except* lets you handle each exception type within the group separately…

  5. What does the Python 3.12 generic syntax (PEP 695) look like, and how do `TypeVar`, `ParamSpec` and `Self` fit in?

    Python 3.12 lets you declare type parameters inline: def firstT -> T and class Box[T]:, plus type aliases (type Pair[T] = tuple[T, T]), replacing manual TypeVar declarations. ParamSpec captures a…

  6. What are metaclasses, and when is `__init_subclass__` a simpler alternative?

    A metaclass is the class of a class (type by default); it controls class creation (new/init on the metaclass), enabling registries, validation or auto-generated attributes. init_subclass (Python…

  7. What does a modern Python toolchain look like?

    uv (fast installer, resolver, venv and Python version manager with lockfiles) or Poetry/PDM for project management, pyproject.toml for configuration, Ruff for linting and formatting, mypy or pyright…

  8. What is the walrus operator (`:=`) and when is it useful?

    The assignment expression := (Python 3.8) assigns a value as part of an expression, which avoids repeating computations in conditions, comprehensions and loops.

  9. What notable improvements came in Python 3.11 through 3.14?

    3.11: big speedups (Faster CPython), exception groups, TaskGroup, tomllib, better error locations. 3.12: PEP 695 generics syntax, f-string grammar improvements, per-interpreter GIL groundwork. 3.13:…

  10. What are template strings (t-strings) in Python 3.14?

    t-strings (t"Hello {name}", PEP 750) look like f-strings but evaluate to a Template object containing the static parts and interpolated values separately, instead of a final string, so libraries can…

  11. What are weak references in Python and when do you use them?

    weakref.ref, WeakValueDictionary and WeakKeyDictionary reference objects without increasing their reference count, so caches and observer registries don't keep objects alive.

  12. What are the pitfalls of `multiprocessing`?

    Arguments and results must be picklable and are copied between processes (overhead for large data), start methods differ by OS (spawn vs fork; fork is unsafe with threads and no longer the default…

  13. What are common security pitfalls in Python applications?

    eval/exec on input, unsafe deserialization (pickle, yaml.load without SafeLoader), SQL built with f-strings, shell=True subprocesses, path traversal in file handling, weak randomness (random instead…

  14. What do `send()`, `throw()`, `close()` and `yield from` do with generators?

    send(value) resumes a generator and makes the current yield expression evaluate to value; throw() raises an exception at the yield point; close() raises GeneratorExit for cleanup; yield from…

  15. What goes into a modern `pyproject.toml`?

    The [build-system] table (backend such as hatchling or setuptools), [project] metadata (name, version, dependencies, optional-dependencies, requires-python, scripts), and tool configuration…

  16. What are subinterpreters in Python 3.14?

    Python 3.14 exposes multiple isolated interpreters in one process through the concurrent.interpreters module (PEP 734) and an InterpreterPoolExecutor; each interpreter has its own GIL, enabling CPU…

Was this page helpful?

Report a mistake