Skip to content

syntactic sugar

In programming languages, syntactic sugar is a piece of syntax designed to make code easier to read or write without changing what the language can compute. Peter J. Landin coined the term in 1964 to describe surface forms whose meaning is defined by translation into a smaller core of language primitives.

A construct qualifies as syntactic sugar when removing it would not reduce expressive power, because any program written with it can be rewritten using the underlying constructs.

Common examples appear across many languages:

  • Array indexing: writing a[i] desugars to the pointer dereference *(a + i) in C.
  • List comprehensions: a comprehension like [f(x) for x in items] desugars to an explicit for loop.
  • Decorators: a decorator like @dec above a definition desugars to the plain function call func = dec(func). Python’s documentation explicitly calls decorator syntax syntactic sugar.
  • f-strings: an f-string desugars to equivalent str.format() calls or string concatenation.
  • Operators: a + b desugars to a magic method call like a.__add__(b).

Critics argue that excessive sugar complicates language specifications and tooling, while proponents view it as essential for ergonomics and readability.

Tutorial

Syntactic Sugar: Why Python Is Sweet and Pythonic

In this tutorial, you'll learn what syntactic sugar is and how Python uses it to help you create more readable, descriptive, clean, and Pythonic code. You'll also learn how to replace a given piece of syntactic sugar with another syntax construct.

intermediate best-practices python

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated June 10, 2026 • Reviewed by Leodanis Pozo Ramos