Expressions¶
Operators¶
Boolean Operators¶
LisPy version
Python versionBinary Operators¶
LisPy version
Python versionUnary Operators¶
LisPy version
Python versionnot¶
LisPy version
Python version~¶
LisPy version
Python versionComparison Operators¶
==¶
LisPy version
Python version>¶
LisPy version
Python version!=¶
LisPy version
Python version<¶
LisPy version
Python version<=¶
LisPy version
Python version>=¶
LisPy version
Python versionis¶
LisPy version
Python versionis-not¶
LisPy version
Python versionin¶
LisPy version
Python versionnot-in¶
LisPy version
Python version:=¶
LisPy version
Python versionStatements are not expressions¶
Statement forms (do, =, +=, if, return, def, ...) cannot appear inside an expression; the compiler reports an error. Use (:= name value) instead of =, (ife test then else) instead of if, and a tuple (sub (, a b c) -1) to sequence expressions.
lambda¶
LisPy version
Python versionif expression¶
LisPy version
Python versionCollection Literals¶
List¶
LisPy version
Python versionDictionary¶
LisPy version
Python versionSet¶
LisPy version
Python versionTuple¶
LisPy version
Python versionComprehensions¶
List Comprehension¶
LisPy version
Python versionDictionary Comprehension¶
LisPy version
Python versionSet Comprehension¶
LisPy version
Python versionGenerator Expression¶
LisPy version
Python versionComprehension Unpacking¶
Python 3.15+ (PEP 798). On an older Python these forms are a compile error naming the version they need.
LisPy version
[*L for L in lists]
(*L for L in lists)
{, *s for s in sets}
{**d for d in dicts}
[*L async-for L in lists]
[*L for L in lists]
(*L for L in lists)
{*s for s in sets}
{**d for d in dicts}
[*L async for L in lists]
await¶
LisPy version
Python versionyield¶
LisPy version
Python versionyield from¶
LisPy version
Python versionFunction Call¶
LisPy version
Python versionFormatted String Literals¶
LisPy version
Python version Replacement fields follow Python's rules:{{/}} are literal braces,
!r/!s/!a conversions, format specs with nested fields, and {x=}.
A field is ordinary code, so a string in it is written with plain quotes as in
Python 3.12+ (f"{(.get d "k")}"), on every supported Python. The old
spelling with \" (f"{(.get d \"k\")}") is deprecated: it still compiles,
with a SyntaxWarning (shown by default, as for an invalid escape sequence
in Python 3.12+), and a string opened with \" must be closed by
\".
LisPy version
Python version
Template String Literals¶
Python 3.14+ (PEP 750). The t prefix
combines with r like f does (rt"...", Tr"...") and builds a
string.templatelib.Template. Each interpolation's expression is the LisPy
text inside the braces. On an older Python a t-string is a compile error naming
the version it needs.
LisPy version
Python versionAttribute¶
Two forms read an attribute: a dotted name, and (. obj attr).
Dotted Name¶
A name with dots in it is Python's attribute access. It chains, and it works
anywhere a name does: as a value, a call head, an assignment or del target,
and in import.
LisPy version
Python version Every part is an ordinary name, so hyphens become underscores (a.b-c is
a.b_c). The dotted name must be one token that starts with a name: a.
and a..b are errors, a lone .a as a value is an error ((.a obj) is the
method-call form below), and a.b[0] is refused (use (sub a.b 0)).
(. obj attr)¶
The object may be any expression, which a dotted name cannot be: a literal,
call, subscription or other form on the left of the dot is not read as
attribute access ((f).x and "s".upper are errors). (. obj attr) takes
the attribute names after the object, so more than one chains them.
LisPy version
Python version Each attribute must be a plain name, so(. obj (method)) is an error: to
call a method on an expression use the method-call form below.
Method Call¶
LisPy version
Python versionSubscription¶
Simple Subscription¶
LisPy version
Python versionTuple Subscription¶
LisPy version
Python versionSlice¶
Slice Subscription¶
LisPy version
Python versionSlice with Emptiness¶
LisPy version
Python version