summaryrefslogtreecommitdiff
path: root/README.rst
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2020-10-11 11:54:37 +0100
committerMichael Williamson <mike@zwobble.org>2020-10-11 11:57:34 +0100
commit14393f779c2c9e2e0c99863b193738ba29a6660a (patch)
tree4ea399a48c4dc3821526544e5b3c5b34a5e2460a /README.rst
parent54467df8c6f06c2d4421ab5d0446d7cd8f5040e1 (diff)
Add support for predefined variables
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst7
1 files changed, 7 insertions, 0 deletions
diff --git a/README.rst b/README.rst
index d331181..affe1f2 100644
--- a/README.rst
+++ b/README.rst
@@ -106,6 +106,13 @@ Call ``iter()`` to get all of the output elements as an iterator:
assert next(iterator, None) == 4
assert next(iterator, None) == None
+Calling ``compile()`` with the ``args`` argument allows predefined variables to be used within the program:
+
+.. code-block:: python
+
+ program = jq.compile("$a + $b + .", args={"a": 100, "b": 20})
+ assert program.input(3).first() == 123
+
Convenience functions are available to get the output for a program and input in one call:
.. code-block:: python