A quick translation table from Python to Hy.
Hy is a Lisp parser for Python.
It parses Lisp code into Python syntax to be executed by the Python interpreter.
See also
The Nature of Lisp,
Casting SPELs in Lisp,
Practical Common Lisp.
- Earmuffs become uppercase (
*foo*
-> FOO
)
- Dashes become underscores (
--name--
-> __name__
)
Categories:
assignment:
methods:
multi-statement blocks:
classes:
let creates temporary
variables which only exist in its body:
Control Flow
if
(lispers prefer cond):
when and
unless are
simple one-branch conditionals.
while:
for:
try:
with:
Built-In Sequences
built-in sequences:
list,
set,
dict
comprehensions and
genexprs:
indexing:
item assignment:
variable/index/item deletion:
slicing:
Importing
import:
To import Hy modules in Python, you must first import hy
.
To use macros defined in another module, you must use
require.
Functions
defining functions:
unpacking argument lists:
lambdas:
decorators:
Macros
defmacro
quasiquote
unquote
unquote-splice