Skip to content

LearnXinY Reference

Quadstronaut edited this page Jun 7, 2026 · 1 revision

LearnXinY Reference

The LearnXinY/ directory is a structured transcription of the Learn X in Y Minutes — Python guide (© its contributors, CC BY-SA 3.0), expanded with original examples co-authored with Claude (Anthropic), also released under CC BY-SA 3.0.

Each file is self-contained and runnable. Read top-to-bottom: examples appear as expressions with # => result comments, followed by print statements that actually execute. No imports are needed unless a file explicitly imports something.

Topic index

Primitives

File Key concepts covered
Primitives/numbers.py Integer arithmetic, floor division, modulo, exponentiation, operator precedence; floats, IEEE 754 rounding, round(), abs(), divmod(), pow(); walrus operator (:=), bit_length()
Primitives/strings.py String creation, single/double/triple quotes; slicing, len(), concatenation, repetition; methods (upper, lower, strip, split, join, replace, startswith, find); f-strings, format(), %; str.translate()
Primitives/booleans_and_none.py True/False, and/or/not; comparison operators; short-circuit evaluation; None; truthiness of empty containers

Variables

File Key concepts covered
Variables/assignment.py Simple assignment; multiple assignment; tuple unpacking; swap without temp; augmented assignment (+=, -=, etc.); type annotations

Collections

File Key concepts covered
Collections/lists.py Creation, indexing (positive and negative), slicing, append, insert, remove, pop, sort, sorted, reverse, copy, extend, in
Collections/tuples.py Immutability, creation, single-element tuple, unpacking, namedtuple; memory advantage over lists
Collections/dictionaries.py Creation, access, .get(), .keys(), .values(), .items(); mutation, deletion; merging (`
Collections/sets.py Creation, membership test; union (`

Control Flow

File Key concepts covered
ControlFlow/conditionals.py if/elif/else; ternary expression; match/case (Python 3.10+); guard clauses
ControlFlow/loops.py for loops, while loops; range(); enumerate(); zip(); break/continue/else on loops
ControlFlow/exceptions.py try/except/else/finally; catching multiple exceptions; raise; custom exception classes; context managers (with)
ControlFlow/comprehensions.py List, set, and dict comprehensions; filter conditions; nested comprehensions; generator expressions; when to use each form

Functions

File Key concepts covered
Functions/basics.py def, return; default arguments; scope (global, local); first-class functions; map()/filter(); functools.lru_cache
Functions/args_and_kwargs.py *args; **kwargs; keyword-only arguments; positional-only arguments (/); unpacking at call site (*list, **dict)
Functions/closures_and_lambdas.py Closures; nonlocal; lambda; operator module (operator.add, etc.)
Functions/decorators.py @decorator syntax; functools.wraps; decorators with arguments; stacking decorators; class-based decorators
Functions/generators.py yield; generator expressions; yield from; .send(); generator pipelines

Modules

File Key concepts covered
Modules/imports.py import; from ... import; aliases (as); import * (and why to avoid it); dir(), help(); stdlib highlights; importlib.import_module(); sys.path; __name__ guard

Classes

File Key concepts covered
Classes/basics.py class, __init__, instance attributes; __str__, __repr__; @dataclass
Classes/properties_and_statics.py @property, setter; @classmethod; @staticmethod; functools.cached_property
Classes/inheritance.py Single inheritance; super(); method overriding; multiple inheritance; MRO (__mro__); ABC/@abstractmethod; mixin pattern
Classes/magic_methods.py Arithmetic dunders (__add__, __sub__, __mul__, __rmul__, __neg__, __abs__); __eq__, __hash__; container protocol (__len__, __getitem__, __iter__, __contains__); __bool__; context manager (__enter__/__exit__); __call__

How to run

Any file can be run directly:

python LearnXinY/Classes/magic_methods.py
python LearnXinY/Functions/generators.py

Most files produce no output unless they explicitly call print(). The # => value comment pattern is readable without running the file. Files with print statements at the bottom (or in the original-examples section) will produce output.

Source attribution

Every LearnXinY/ file carries this header:

# Source: https://learnxinyminutes.com/python/  (CC BY-SA 3.0)
# Organization inspired by learnxinyminutes.com

Original supplemental examples (the block below # ORIGINAL EXAMPLES (co-authored with Claude)) are © the repository contributors and also released under CC BY-SA 3.0.

Clone this wiki locally