This documentation is auto-generated from the test suite. Do not edit manually.
Tests as-form emission in except clauses.
Lisp S-Expression:
(try (setf a 1) ((as Exception e) (setf a 2)))Generated Python (after formatting):
try:
a = 1
except Exception as e:
a = 2 (return 1)
(return 2))`
Tests if/else emission.
Lisp S-Expression:
(if (== a b)
(return 1)
(return 2))Generated Python (after formatting):
if a == b:
return 1
else:
return 2Tests when emission.
Lisp S-Expression:
(when (> a b) (return a))Generated Python (after formatting):
if a > b:
return aTests unless emission.
Lisp S-Expression:
(unless (> a b) (return b))Generated Python (after formatting):
if not a > b:
return bTests while loop emission.
Lisp S-Expression:
(while (< a b) (setf a (+ a 1)))Generated Python (after formatting):
while a < b:
a = a + 1Tests for loop emission.
Lisp S-Expression:
(for (i (range 3)) (print i))Generated Python (after formatting):
for i in range(3):
print(i)Tests for-generator emission.
Lisp S-Expression:
(for-generator (i (range 3)) (* i 2))Generated Python (after formatting):
i*2 for i in range(3)Tests with-statement emission.
Lisp S-Expression:
(with (open (string "f.txt")) (setf data (dot f read)))Generated Python (after formatting):
with open("f.txt"):
data = f.readTests with-statement emission using 'as'.
Lisp S-Expression:
(with (as (open (string "f.txt")) f) (setf data (dot f read)))Generated Python (after formatting):
with open("f.txt") as f:
data = f.read (finally (setf a 4)))`
Tests try/except/else/finally emission.
Lisp S-Expression:
(try (setf a 1) (Exception (setf a 2)) (else (setf a 3)) (finally (setf a 4)))Generated Python (after formatting):
try:
a = 1
except Exception:
a = 2
else:
a = 3
finally:
a = 4Tests cond emission.
Lisp S-Expression:
(cond ((> a b) (return a)) ((< a b) (return b)) (t (return 0)))Generated Python (after formatting):
if a > b:
return a
elif a < b:
return b
else:
return 0Tests ternary emission.
Lisp S-Expression:
(? (> a b) a b)Generated Python (after formatting):
a if a > b else bTests return_ emission inside a function.
Lisp S-Expression:
(def foo nil (return_ (x)))Generated Python (after formatting):
def foo():
return xTests try/except block using string directly for except clause.
Lisp S-Expression:
(try (setf a 1) ("Exception as e" (print e)))Generated Python (after formatting):
try:
a = 1
except Exception as e:
print(e) (for (i (range 5))
(if (== i 2)
break
continue)))`
Tests loop control statements break and continue.
Lisp S-Expression:
(do0
(for (i (range 5))
(if (== i 2)
break
continue)))Generated Python (after formatting):
for i in range(5):
if i == 2:
break
else:
continueTests yield statement and yield function call variants.
Lisp S-Expression:
(do0 yield (yield x))Generated Python (after formatting):
yield
yield (x) (ntuple (as (open (string "a.txt")) f) (as (open (string "b.txt")) g))
(setf a 1))`
Tests with-statement with multiple context managers using ntuple.
Lisp S-Expression:
(with (ntuple (as (open (string "a.txt")) f) (as (open (string "b.txt")) g))
(setf a 1))Generated Python (after formatting):
with open("a.txt") as f, open("b.txt") as g:
a = 1Tests with-statement with a simple variable context manager.
Lisp S-Expression:
(with conn (setf a 1))Generated Python (after formatting):
with conn:
a = 1Tests looping over a sequence variable (without explicit range/function call).
Lisp S-Expression:
(for (x items) (print x))Generated Python (after formatting):
for x in items:
print(x)Tests nested ternary operations with precedence-aware parenthesis formatting.
Lisp S-Expression:
(setf x (? c1 a (? c2 b d)))Generated Python (after formatting):
x = a if c1 else b if c2 else dTests unpacking multiple loop variables directly inside a for loop.
Lisp S-Expression:
(for ((ntuple root folders files) (os.walk (string "."))) (print root))Generated Python (after formatting):
for root, folders, files in os.walk("."):
print(root)Tests try-except clause with a tuple of exceptions.
Lisp S-Expression:
(try (f) ((tuple KeyError ValueError) (print (string "error"))))Generated Python (after formatting):
try:
f()
except (
KeyError,
ValueError,
):
print("error")Tests a simple function definition with one argument and a return statement.
Lisp S-Expression:
(def foo (x) (return x))Generated Python (after formatting):
def foo(x):
return x b 2)`
Tests 'setf' for assigning multiple variables in sequence.
Lisp S-Expression:
(setf a 1
b 2)Generated Python (after formatting):
a = 1
b = 2Tests direct assignment emission.
Lisp S-Expression:
(= a 1)Generated Python (after formatting):
a = 1Tests list literal emission.
Lisp S-Expression:
(list 1 2)Generated Python (after formatting):
[1, 2]Tests tuple literal emission.
Lisp S-Expression:
(tuple 1 2 3)Generated Python (after formatting):
(
1,
2,
3,
)Tests paren emission for comma-separated values.
Lisp S-Expression:
(paren a b)Generated Python (after formatting):
(a, b)Tests ntuple emission without surrounding parentheses.
Lisp S-Expression:
(ntuple a b c)Generated Python (after formatting):
a, b, cTests curly emission for set literals.
Lisp S-Expression:
(curly 1 2 3)Generated Python (after formatting):
{1, 2, 3}Tests dict literal emission with explicit key/value pairs.
Lisp S-Expression:
(dict ((string "a") 1) ((string "b") 2))Generated Python (after formatting):
{("a"): (1), ("b"): (2)}Tests keyword-based dictionary constructor emission.
Lisp S-Expression:
(dictionary :a 1 :b 2)Generated Python (after formatting):
dict(a=1, b=2)Tests array reference emission.
Lisp S-Expression:
(aref arr 1)Generated Python (after formatting):
arr[1]Tests slice emission inside indexing.
Lisp S-Expression:
(aref arr (slice 1 2))Generated Python (after formatting):
arr[1:2]Tests slice emission with a step.
Lisp S-Expression:
(aref arr (slice 1 5 2))Generated Python (after formatting):
arr[1:5:2]Tests slice emission with an open start.
Lisp S-Expression:
(aref arr (slice nil 3))Generated Python (after formatting):
arr[:3]Tests slice emission with an open end.
Lisp S-Expression:
(aref arr (slice 1 nil))Generated Python (after formatting):
arr[1:]Tests multi-index emission.
Lisp S-Expression:
(aref arr i j)Generated Python (after formatting):
arr[i, j]Tests dot form emission.
Lisp S-Expression:
(dot obj attr)Generated Python (after formatting):
obj.attrTests keyword argument emission in function calls.
Lisp S-Expression:
(foo 1 :bar 2 :baz 3)Generated Python (after formatting):
foo(1, bar=2, baz=3)Tests keyword-only call emission.
Lisp S-Expression:
(foo :bar 2)Generated Python (after formatting):
foo(bar=2)Tests string literal emission.
Lisp S-Expression:
(string "hi")Generated Python (after formatting):
"hi"Tests byte string literal emission.
Lisp S-Expression:
(string-b "data")Generated Python (after formatting):
b"data"Tests triple-quoted string literal emission.
Lisp S-Expression:
(string3 "block")Generated Python (after formatting):
"""block"""Tests raw triple-quoted string literal emission.
Lisp S-Expression:
(rstring3 "raw")Generated Python (after formatting):
r"""raw"""Tests f-string emission.
Lisp S-Expression:
(fstring "{x}")Generated Python (after formatting):
f"{x}"Tests triple-quoted f-string emission.
Lisp S-Expression:
(fstring3 "{x}")Generated Python (after formatting):
f"""{x}"""Tests single line comment emission.
Lisp S-Expression:
(comment "note")Generated Python (after formatting):
# noteTests multi-line comment emission.
Lisp S-Expression:
(comments "line1" "line2")Generated Python (after formatting):
# line1
# line2Tests symbol emission with hyphen to colon conversion.
Lisp S-Expression:
(symbol foo-bar)Generated Python (after formatting):
foo: barTests lambda emission with a single expression body.
Lisp S-Expression:
(lambda (x) (+ x 1))Generated Python (after formatting):
lambda x: x + 1Tests class emission with a simple initializer.
Lisp S-Expression:
(class Foo nil (def __init__ (self x) (setf (dot self x) x)))Generated Python (after formatting):
class Foo:
def __init__(self, x):
self.x = xTests class emission with a parent class.
Lisp S-Expression:
(class Child (Base) (def __init__ (self) (return 1)))Generated Python (after formatting):
class Child(Base):
def __init__(self):
return 1Tests do0 emission without extra indentation.
Lisp S-Expression:
(do0 (setf a 1) (setf b 2))Generated Python (after formatting):
a = 1
b = 2Tests cell emission with export comment.
Lisp S-Expression:
(cell (setf a 1))Generated Python (after formatting):
# export
a = 1Tests space emission.
Lisp S-Expression:
(space alpha beta)Generated Python (after formatting):
alpha betaTests assigning to a specific index via aref inside setf.
Lisp S-Expression:
(setf (aref u2 0 0) v)Generated Python (after formatting):
u2[0, 0] = v (declare (type float e)
(type list y)
(type float t_max)
(values list))
(return y))`
Tests function definitions with parameter and return type declarations.
Lisp S-Expression:
(def simulate (e y &key (t_max 1.0))
(declare (type float e)
(type list y)
(type float t_max)
(values list))
(return y))Generated Python (after formatting):
def simulate(e: float, y: list, t_max: float = 1.0) -> list:
return yTests async function definitions using space construct.
Lisp S-Expression:
(space async (def time_generator nil (return 1)))Generated Python (after formatting):
async def time_generator():
return 1Tests function decorators using the symbol fallback starting with @.
Lisp S-Expression:
(do0 (@rt (string "/")) (def get (request) (return 1)))Generated Python (after formatting):
@rt("/")
def get(request):
return 1Tests dictionary comprehension using curly, for-generator and slice.
Lisp S-Expression:
(curly (for-generator ((ntuple i s) (enumerate chars)) (slice s (+ i 1))))Generated Python (after formatting):
{s: i + 1 for i, s in enumerate(chars)}Tests list comprehension using list and for-generator.
Lisp S-Expression:
(list (for-generator (r responses) r))Generated Python (after formatting):
[r for r in responses]Tests keyword argument unpacking in function calls.
Lisp S-Expression:
(func **tub.input)Generated Python (after formatting):
func(**tub.input)Tests function definitions with *args and **kwargs unpacking parameters.
Lisp S-Expression:
(def foo (self *args **kwargs) (return 1))Generated Python (after formatting):
def foo(self, *args, **kwargs):
return 1Tests function/constructor call with no arguments.
Lisp S-Expression:
(foo)Generated Python (after formatting):
foo()Tests single-float and double-float number representations.
Lisp S-Expression:
(tuple 2.2 2.2d0)Generated Python (after formatting):
(
2.2,
2.2,
)Tests representation of complex numbers.
Lisp S-Expression:
#C(1.0 2.0)Generated Python (after formatting):
1.0 + 1j * 2.0Tests raw string in function call position.
Lisp S-Expression:
("list" generator)Generated Python (after formatting):
list(generator)Tests empty slice and slice with raw strings.
Lisp S-Expression:
(tuple (aref xf (slice)) (aref xf (slice "" max_len)))Generated Python (after formatting):
(
xf[:],
xf[:max_len],
)Tests paren* construct for precedence-aware parentheses.
Lisp S-Expression:
(tuple (paren* * (+ a b)) (paren* + (+ a b)))Generated Python (after formatting):
(
(a + b),
a + b,
)Tests raw code insertion via bare strings at block level.
Lisp S-Expression:
(do0 "df = pd.read_csv('data.csv')" "@threaded" (def func nil (return 1)))Generated Python (after formatting):
df = pd.read_csv("data.csv")
@threaded
def func():
return 1Tests lambda functions with zero or multiple arguments.
Lisp S-Expression:
(tuple (lambda () 42) (lambda (x y) (+ x y)))Generated Python (after formatting):
(
lambda: 42,
lambda x, y: x + y,
)Tests calling superclass methods in Python.
Lisp S-Expression:
(tuple (super) (super ImageModel self))Generated Python (after formatting):
(
super(),
super(ImageModel, self),
)Tests chained dot access including functions and array references.
Lisp S-Expression:
(dot model (aref weights i j) (item))Generated Python (after formatting):
model.weights[i, j].item()Tests assignment to unpacked values on the left hand side.
Lisp S-Expression:
(setf (ntuple a b) (tuple 1 2))Generated Python (after formatting):
a, b = (
1,
2,
)Tests 'export' comment cell construct.
Lisp S-Expression:
(export (setf a 1))Generated Python (after formatting):
# |export
a = 1Tests standalone 'indent' formatting construct.
Lisp S-Expression:
(indent a)Generated Python (after formatting):
aTests lambda expression with keyword arguments.
Lisp S-Expression:
(lambda (x &key (y 2)) (+ x y))Generated Python (after formatting):
lambda x, y=2: x + yTests raw string index insertion inside aref.
Lisp S-Expression:
(aref arr ":" 0)Generated Python (after formatting):
arr[:, 0]Tests empty dict literal and empty dictionary constructor.
Lisp S-Expression:
(tuple (dict) (dictionary))Generated Python (after formatting):
(
{},
dict(),
) (def f3 nil (return (ntuple x y))))`
Tests return statement variants including empty return, single value, and multi-value returns.
Lisp S-Expression:
(do0 (def f1 nil (return)) (def f2 nil (return x))
(def f3 nil (return (ntuple x y))))Generated Python (after formatting):
def f1():
return
def f2():
return x
def f3():
return x, yTests standalone 'pass' statement representation.
Lisp S-Expression:
(def f nil pass)Generated Python (after formatting):
def f():
passTests set comprehension using curly braces and for-generator.
Lisp S-Expression:
(curly (for-generator (x (range 5)) x))Generated Python (after formatting):
{x for x in range(5)}Tests nested function definition emission.
Lisp S-Expression:
(def outer (x) (def inner (y) (return (+ x y))) (return inner))Generated Python (after formatting):
def outer(x):
def inner(y):
return x + y
return innerTests nested class definition emission.
Lisp S-Expression:
(class Outer nil (class Inner nil (def f (self) pass)))Generated Python (after formatting):
class Outer:
class Inner:
def f(self):
passTests default parameters in function definitions with expression values.
Lisp S-Expression:
(def foo (x &key (y (+ 1 2))) (return (* x y)))Generated Python (after formatting):
def foo(x, y=1 + 2):
return x * yTests slice with open bounds and a negative step value.
Lisp S-Expression:
(aref arr (slice nil nil -1))Generated Python (after formatting):
arr[::-1]Tests function definition with only keyword arguments.
Lisp S-Expression:
(def foo (&key (x 1) (y 2)) (return (+ x y)))Generated Python (after formatting):
def foo(x=1, y=2):
return x + yTests symbol emission containing dots as member access.
Lisp S-Expression:
(setf image.flags.writeable False)Generated Python (after formatting):
image.flags.writeable = FalseTests symbol fallback for complex number literals like 1j or 0j.
Lisp S-Expression:
(tuple |0J| |1J|)Generated Python (after formatting):
(
0j,
1j,
)Tests raw code insertion inside an expression using a bare string.
Lisp S-Expression:
(- "1/8" x)Generated Python (after formatting):
1 / 8 - x y 123456.78901234567d0
z 1.0d-20
w 1.0d30)`
Tests that float literals are emitted with enough digits to read back as the very same number.
Lisp S-Expression:
(setf x 0.3333333333333333d0
y 123456.78901234567d0
z 1.0d-20
w 1.0d30)Generated Python (after formatting):
x = 0.3333333333333333
y = 123456.78901234567
z = 1.0e-20
w = 1.0e30Verifies that an emitted double float literal is bit-identical to the value Python computes.
Lisp S-Expression:
(print (== 0.3333333333333333d0 (/ 1 3)))Generated Python (after formatting):
print(0.3333333333333333 == (1 / 3))Tests the two-argument ternary as the filter of a comprehension (the else branch is omitted).
Lisp S-Expression:
(list (? (> x 0) (for-generator (x xs) x)))Generated Python (after formatting):
[x for x in xs if x > 0]Tests single import emission.
Lisp S-Expression:
(import sys)Generated Python (after formatting):
import sysTests import emission with alias.
Lisp S-Expression:
(import (np numpy))Generated Python (after formatting):
import numpy as npTests multiple import emissions with aliases.
Lisp S-Expression:
(imports (sys (np numpy) (plt matplotlib.pyplot)))Generated Python (after formatting):
import sys
import numpy as np
import matplotlib.pyplot as pltTests from-import emission.
Lisp S-Expression:
(import-from math sin cos)Generated Python (after formatting):
from math import sin, cosTests multiple from-import emissions.
Lisp S-Expression:
(imports-from (math sin cos) (pathlib Path))Generated Python (after formatting):
from math import sin, cos
from pathlib import PathTests the '+' operator with two integer arguments.
Lisp S-Expression:
(+ 1 2)Generated Python (after formatting):
1 + 2Tests incf emission with explicit increment.
Lisp S-Expression:
(incf a 2)Generated Python (after formatting):
a += 2Tests decf emission with explicit decrement.
Lisp S-Expression:
(decf a 3)Generated Python (after formatting):
a -= 3Tests logical and emission.
Lisp S-Expression:
(and a b)Generated Python (after formatting):
a and bTests logical or emission.
Lisp S-Expression:
(or a b)Generated Python (after formatting):
a or bTests equality comparison emission.
Lisp S-Expression:
(== a b)Generated Python (after formatting):
a == bTests inequality comparison emission.
Lisp S-Expression:
(!= a b)Generated Python (after formatting):
a != bTests less-than comparison emission.
Lisp S-Expression:
(< a b)Generated Python (after formatting):
a < bTests less-than-or-equal comparison emission.
Lisp S-Expression:
(<= a b)Generated Python (after formatting):
a <= bTests greater-than comparison emission.
Lisp S-Expression:
(> a b)Generated Python (after formatting):
a > bTests greater-than-or-equal comparison emission.
Lisp S-Expression:
(>= a b)Generated Python (after formatting):
a >= bTests membership comparison emission.
Lisp S-Expression:
(in a b)Generated Python (after formatting):
(a in b)Tests negative membership comparison emission.
Lisp S-Expression:
(not-in a b)Generated Python (after formatting):
(a not in b)Tests identity comparison emission.
Lisp S-Expression:
(is a b)Generated Python (after formatting):
(a is b)Tests negative identity comparison emission.
Lisp S-Expression:
(is-not a b)Generated Python (after formatting):
(a is not b)Tests modulo operator emission.
Lisp S-Expression:
(% a b)Generated Python (after formatting):
a % bTests subtraction operator emission.
Lisp S-Expression:
(- a b)Generated Python (after formatting):
a - bTests multiplication operator emission.
Lisp S-Expression:
(* a b c)Generated Python (after formatting):
a * b * cTests division operator emission.
Lisp S-Expression:
(/ a b)Generated Python (after formatting):
a / bTests matrix-multiplication operator emission.
Lisp S-Expression:
(@ a b)Generated Python (after formatting):
a @ bTests floor division operator emission.
Lisp S-Expression:
(// a b)Generated Python (after formatting):
a // bTests exponentiation operator emission.
Lisp S-Expression:
(** a b)Generated Python (after formatting):
a**bTests left shift operator emission.
Lisp S-Expression:
(<< a b)Generated Python (after formatting):
a << bTests right shift operator emission.
Lisp S-Expression:
(>> a b)Generated Python (after formatting):
a >> bTests bitwise and operator emission.
Lisp S-Expression:
(& a b)Generated Python (after formatting):
a & bTests logand emission.
Lisp S-Expression:
(logand a b c)Generated Python (after formatting):
a & b & cTests bitwise xor operator emission.
Lisp S-Expression:
(^ a b)Generated Python (after formatting):
a ^ bTests logxor emission.
Lisp S-Expression:
(logxor a b)Generated Python (after formatting):
a ^ bTests bitwise or operator emission.
Lisp S-Expression:
(|\|| a b)Generated Python (after formatting):
a | bTests bitwise or operator emission.
Lisp S-Expression:
(logior a b c)Generated Python (after formatting):
a | b | cVerifies that the generated code for '+' executes correctly.
Lisp S-Expression:
(print (+ 5 8))Generated Python (after formatting):
print(5 + 8)Tests unary minus and unary division operators.
Lisp S-Expression:
(tuple (- x) (/ x))Generated Python (after formatting):
(
-x,
1.0 / x,
)Tests unary bitwise negation operator.
Lisp S-Expression:
(~ x)Generated Python (after formatting):
~xTests unary logical negation operator.
Lisp S-Expression:
(not a)Generated Python (after formatting):
not aTests chained comparison operators with multiple arguments.
Lisp S-Expression:
(tuple (< a b c) (<= x y z) (== d e f))Generated Python (after formatting):
(
a < b < c,
x <= y <= z,
d == e == f,
)Tests logical and/or operators with more than two arguments.
Lisp S-Expression:
(tuple (and a b c) (or d e f))Generated Python (after formatting):
(
a and b and c,
d or e or f,
)Tests bitwise and/xor/or operators with more than two arguments.
Lisp S-Expression:
(tuple (logand a b c) (logxor x y z) (logior p q r))Generated Python (after formatting):
(
a & b & c,
x ^ y ^ z,
p | q | r,
)Tests logical not precedence parenting.
Lisp S-Expression:
(tuple (not (== a b)) (not (and a b)))Generated Python (after formatting):
(
not a == b,
not (a and b),
)Tests matrix multiplication chaining with multiple operands.
Lisp S-Expression:
(@ a b c)Generated Python (after formatting):
a @ b @ cTests division with more than two arguments (left associative, like Common Lisp and Python).
Lisp S-Expression:
(/ a b c)Generated Python (after formatting):
a / b / cTests floor division with more than two arguments.
Lisp S-Expression:
(// a b c)Generated Python (after formatting):
a // b // cTests that a unary minus below ** keeps its parentheses: python reads -a2 as -(a2).
Lisp S-Expression:
(** (- a) 2)Generated Python (after formatting):
(-a) ** 2Tests that a negative literal below ** keeps its parentheses.
Lisp S-Expression:
(print (** -2 2))Generated Python (after formatting):
print((-2) ** 2)Tests that the one-argument division below ** keeps its parentheses.
Lisp S-Expression:
(** (/ a) 2)Generated Python (after formatting):
(1.0 / a) ** 2Tests that a comparison inside a comparison keeps its parentheses: python chains a==b==c.
Lisp S-Expression:
(== a (== b c))Generated Python (after formatting):
a == (b == c)Tests that a comparison keeps its parentheses on either side of a comparison.
Lisp S-Expression:
(print (== (< 1 2) (< 3 4)))Generated Python (after formatting):
print((1 < 2) == (3 < 4))Tests that an n-ary comparison is emitted as a python comparison chain, like in Common Lisp.
Lisp S-Expression:
(print (< 1 2 3))Generated Python (after formatting):
print(1 < 2 < 3)Tests that a shift as the right operand of a shift keeps its parentheses (<< is left associative).
Lisp S-Expression:
(print (<< 1 (>> 8 1)))Generated Python (after formatting):
print(1 << (8 >> 1))Tests that @ and * keep their parentheses inside each other although they share a precedence level.
Lisp S-Expression:
(tuple (@ a (* b c)) (* a (@ b c)))Generated Python (after formatting):
(
a @ (b * c),
a * (b @ c),
)Tests that operators which are associative with each other stay flat.
Lisp S-Expression:
(tuple (+ a (+ b c)) (* a (* b c)) (and a (and b c)) (logand a (& b c)))Generated Python (after formatting):
(
a + b + c,
a * b * c,
a and b and c,
a & b & c,
)Tests that 'or' below 'and' is parenthesized while 'and' below 'or' is not.
Lisp S-Expression:
(tuple (and a (or b c)) (or a (and b c)))Generated Python (after formatting):
(
a and (b or c),
a or b and c,
)Tests the conditional expression: only the else branch may contain another one without parentheses.
Lisp S-Expression:
(tuple (? c (? d e f) g) (? c a (? d e f)))Generated Python (after formatting):
(
(e if d else f) if c else g,
a if c else e if d else f,
)Tests that the object of a dot form is parenthesized when it is an operator expression.
Lisp S-Expression:
(dot (- a b) c)Generated Python (after formatting):
(a - b).cTests that the sequence of an aref form is parenthesized when it is an operator expression.
Lisp S-Expression:
(print (aref (+ (list 1 2) (list 3)) 2))Generated Python (after formatting):
print(([1, 2] + [3])[2])Tests that indexing and attribute access are not parenthesized inside each other.
Lisp S-Expression:
(tuple (aref (dot a b) i) (dot (aref a i) b) (aref (aref a i) j))Generated Python (after formatting):
(
a.b[i],
a[i].b,
a[i][j],
)Tests that a comparison inside 'in' keeps its parentheses, otherwise python would chain them.
Lisp S-Expression:
(in (== a b) c)Generated Python (after formatting):
((a == b) in c)Tests that a lambda used inside an expression is parenthesized, otherwise its body would swallow the rest.
Lisp S-Expression:
(dot (lambda (x) x) __name__)Generated Python (after formatting):
(lambda x: x).__name__Tests that a bare comma list used inside an expression is parenthesized.
Lisp S-Expression:
(? c (ntuple a b) (ntuple d e))Generated Python (after formatting):
(a, b) if c else (d, e)Tests a negative literal as the right operand of the non-associative operators.
Lisp S-Expression:
(tuple (- a -1) (/ a -1) (* a -1))Generated Python (after formatting):
(
a - (-1),
a / (-1),
a * -1,
)Tests that a complex literal, which is emitted as a sum, is parenthesized when used as an operand.
Lisp S-Expression:
(setf z (+ #C(1.0d0 2.0d0) 1))Generated Python (after formatting):
z = (1.0 + 1j * 2.0) + 1Tests that nested unary operators need no parentheses.
Lisp S-Expression:
(tuple (- (- a)) (~ (~ a)) (not (not a)))Generated Python (after formatting):
(
--a,
~~a,
not not a,
)