Skip to content

Hylang Test.ipynb - In [32]: Show users how to properly unpack keyword arguments #19

@gtoast

Description

@gtoast

In Hylang Test.ipynb:

In [31]:
(defn optional-arg
  [pos1 pos2 &optional keyword1 [keyword2 42]]
  [pos1 pos2 keyword1 keyword2])
  ...
In [32]:
(setv args [1 2])
(setv kwargs {"keyword2" 3 "keyword1" 4})
(optional-arg args kwargs)
Out[32]:
[[1, 2], {'keyword2': 3, 'keyword1': 4}, None, 42]

Which is fine, but probably not what the user wants. Can we add an input after this that will show them how to properly unpack these arguments?

In [32]:
(setv args [1 2])
(setv kwargs {"keyword2" 3 "keyword1" 4})
(optional-arg (unpack-iterable args) (unpack-mapping kwargs))
Out[32]:
[1, 2, 4, 3]

I can make a pull request if you approve.

P.S. Thank you for this work. I threw this into a JupyterLab 3.0 notebook on something called myBinder.org 40 minutes ago and the experience has been ridiculously smooth and enjoyable. Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions