We have some async properties (using @property) and some usual ones. We have to use hy to check if one is async or not using asyncio.iscoroutine function. The problem is we have to use getattr and not . operator, since dot will call the property…
I have defined two macros:
(defmacro property [name type]
`(setv ^(of Optional ~type) ~name None))
(defmacro data-type [vname &rest propertys]
`(with-decorator dataclass
(defclass ~vname []
~propertys)))
When called as:
(data-type…
I have a macro like:
(defmacro test [x] `"~x")
After running it expands to the following:
=> (test abc)
'~x'
Why doesn't it expand to 'abc'?
What is the correct method to unquote inside a string?
I am just starting using Hy.
For example we have this Hy code:
(print "Hy, world!")
And we have two pieces of Python code. Piece one:
print("Some python code")
Piece two:
print("Some other python code")
How to include Hy code into a separate…
For example we have this Hy code:
(print "Hy, world!")
And we have two pieces of Python code. Piece one:
print("Some python code")
Piece two:
print("Some other python code")
How can we make something like this:
print("Some python code")
(print…
I'm unclear on how the outer function provided to walk should work.
The example in documentation referenced here:
https://docs.hylang.org/en/stable/contrib/walk.html
Suggests the outer function can be first which would return the first element of…
I'm trying to debug Hy code in Visual Studio Code. I have downloaded the hy-mode theme and it works great. There's only one problem. The hy-mode theme disables breakpoints.
I can add a breakpoint to my Hy code by switching to a totally unrelated…
This example is a little contrived. The goal is to create a macro that loops over some values and programmatically generates some code.
A common pattern in Python is to initialize the properties of an object at calling time as follows:
(defclass…
What is the syntax for for specifying metaclasses in Hy. I tried the following:
(defclass Metaclass [] )
(defclass Foo [ :meta Metaclass ] )
(defclass Foo [ [:meta Metaclass] ] )
but this did not work
I understand how to use hy.read_str and hy.eval from python to evaluate an hy expression from within python. However, when I use this methodology, imports and globals are not shared between the hy and python environments. Consider this…
I know how to import an hy module into python. All I have to do is create a something.hy file containing hy code and then do the following ...
import hy
import something
something.func('args') # assumes there is an hy function called…
In python, the following code iterates a numpy array (the for loop), and the values of the numpy array are changed:
import numpy
a08_1 = numpy.arange(8).astype(numpy.uint8)
# a08_1: array([0, 1, 2, 3, 4, 5, 6, 7], dtype=uint8)
for x in…
I have written a small hylang program that parses a log. However, when i try to evaluate it, i get the following error:
File "", line 8, column 38
(setv rule (.next irule)))))))
^ LexException: Ran into a…
I am trying to use a python function with named arguments from hy.
I'm using the NLTK library as well.
In python I would do something like this
from nltk.corpus import brown
brown.words(categories='news')
to get a list of words in the 'news'…