Skip to main content
py.stuartsm
  • Home
  • Learn
  • Reference
  • Glossary
  • Projects
  • Search
  • About
  1. Reference
  2. Syntax

Syntax

Statements, expressions, and language forms.

  • *args and **kwargsAccept an arbitrary number of positional or keyword arguments in a function definition.
  • AssignmentBind a name to an object with =, optionally combined with an operator, or applied to several targets at once.
  • f-strings (Formatted String Literals)Embed expressions directly inside a string literal — evaluated and formatted at the moment the literal runs.
  • for/while…elseAn else clause on a loop runs only if the loop finished without hitting a break — genuinely surprising the first time you see it.
  • Indentation and BlocksPython uses consistent indentation, not braces or keywords, to mark where a block of code begins and ends.
  • match StatementStructural pattern matching — compare a value's shape against a series of patterns and run the first one that fits.
  • try / except / else / finallyRun code that might fail, handle specific exceptions, and optionally run cleanup code whether it failed or not.

A Python learning and reference site — read to learn, search to look something up.

  • About
  • Reference
  • Curriculum