From 706376277f0b5d2bf2cecbacf7675a3527b97e16 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Tue, 23 Dec 2014 15:05:36 -0600 Subject: [PATCH] Explaining that :keyword syntax is for post 0.10.1 only --- docs/tutorial.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/tutorial.rst b/docs/tutorial.rst index ffa855c..b179aa3 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -396,20 +396,26 @@ The same thing in Hy:: [1 2 None 42] => (optional-arg 1 2 3 4) [1 2 3 4] + +If you're running a version of Hy past 0.10.1 (eg, git master), +there's also a nice new keyword argument syntax:: + => (optional-arg :keyword1 1 ... :pos2 2 ... :pos1 3 ... :keyword2 4) [3, 2, 1, 4] -Are you familiar with passing in *args and **kwargs in Python?:: +Otherwise, you can always use `apply`. But what's `apply`? + +Are you familiar with passing in `*args` and `**kwargs` in Python?:: >>> args = [1 2] >>> kwargs = {"keyword2": 3 ... "keyword1": 4} >>> optional_arg(*args, **kwargs) -We can reproduce this with "apply":: +We can reproduce this with `apply`:: => (setv args [1 2]) => (setv kwargs {"keyword2" 3