Hasty Briefsbeta

PEP 802 – Display Syntax for the Empty Set

16 days ago
  • #Syntax
  • #Python
  • #PEP
  • PEP 802 proposes a new notation, {/}, to represent the empty set in Python, resembling the mathematical symbol '∅'.
  • The motivation includes improving teachability for beginners and providing a culture-free notation for sets.
  • Current Python lacks a syntax for empty sets, requiring `set()` which can be problematic if `set` is overridden as a variable name.
  • The proposed {/} notation was the most popular in recent discussions, chosen for its simplicity and resemblance to '∅'.
  • The PEP discusses various rejected ideas, including using Unicode characters, changing `{}` to mean an empty set, and other syntax proposals.
  • Backwards compatibility is maintained except for changes to the `repr()` and `str()` of the empty set, which will now display as '{/}'.
  • The PEP includes plans to update documentation to use {/} for teaching and reinforcing the new syntax.
  • No security implications are identified, and a reference implementation is forthcoming.