diff --git a/docs/language/api.rst b/docs/language/api.rst index a59a450..41ea609 100644 --- a/docs/language/api.rst +++ b/docs/language/api.rst @@ -38,6 +38,36 @@ Hy features a number special forms that are used to help generate correct Python AST. The following are "special" forms, which may have behavior that's slightly unexpected in some situations. +import +------ + +`import` is used to import modules, like in Python. There are several forms +of import you can use. + +.. code-block:: clj + ;; Imports each of these modules + ;; + ;; Python: + ;; import sys + ;; import os.path + (import sys os.path) + + ;; Import from a module + ;; + ;; Python: from os.path import exists, isdir, isfile + (import [os.path [exists isdir isfile]]) + + ;; Import with an alias + ;; + ;; Python: import sys as systest + (import [sys :as systest]) + + ;; You can list as many imports as you like of different types. + (import [tests.resources [kwtest function-with-a-dash]] + [os.path [exists isdir isfile]] + [sys :as systest]) + + do / progn ----------