I've been absolutely loving the Hy REPL. However it would speed up my workflow immensely if I could have a set of default imports at startup. Clojure has a way of configuring startup imports via leiningen config. Currently I load the repl this…
I have several Hy Lang code snippets that I use in my python project.
I was wondering if there is a relatively easy way for me to get an Abstract Syntax Tree of the Hy code with some python library or maybe even the Hy compiler itself (I've looked…
There seems to be no documentation on how to use hy on single column pandas operation such as the following. Would appreciate any help:
# simple instantiation to scalar
df['a'] = '2'
# the above can be done like so: (-> df (.assign :a "2")) but…
I am unable to submit multiple lines of Hy to Python without indentation:
import hy
expr=hy.read_str("(+ 1 1)(+ 2 2)")
hy.eval(expr)
=> 2
The second '(+ 2 2)' statement has apparently been ignored.
Obviously Python's raison d'etre is indentation,…
I'm trying to test a hy project with pytest but am having trouble with pytest discovering my tests. What needs to be done so that pytest can pick up tests written in hy? I've made the assumption that tests can be written in hy and discovered by…
First off let me just say I know what I'm doing is not ideal, but I'm trying to write the member? function from The Little Schemer using Hy.
(setv else True)
(defn null? [lst]
" If list is empty return True else False "
(if lst
False
…
I'm trying to create functions in hylang and use them from python but the created functions don't seem to have access to the environment passed to hy.eval.
import hy
env = dict(x=5)
func = hy.eval(hy.read_str('(fn [] x)'), env)
print(func())
The…
The following macro tries to assign a member variable from init argument.
But
name 'self' is not defined
(defmacro optional_assign [x &optional [base self]]
`(lif ~x (setv (. ~base ~x) ~x) (setv (. ~base ~x ) None) ))
(defclass clsa []
…
My .py file looks like:
import hy
import example
foo2()
My .hy file looks like:
(defn foo2 [] (+ 1 1))
.hy file is in same folder as .py file.
If I run .py file I am getting error:
runfile('D:/del/hy2/untitled46.py', wdir='D:/del/hy2')
Reloaded…
I am updating from Hy 0.12.1 to the newest version 0.18.0, and I make heavy use of the import_buffer_to_ast function in my python code.
This function has been removed from hy.importer, I was hoping someone could lead me to a good alternative.
The following do/a macro can auto-insert await when asyncio function is used.
The following also shows usage.
(import asyncio)
(import time)
(defmacro do/a [&rest code]
`(do ~@(lfor p code
(if
(= (cut (str…
Given an entry file main.py like so:
#-*- coding: utf-8 -*-
# -*- mode: python -*-
import hy
import os.path
import hymodule
datas=[(os.path.dirname(hy.__file__), 'hy')]
hymodule.hello_world()
Given a Hy file hymodule.hy:
(defn hello-world []
…
Why hy unknown?
How to use deftag?
Snippet from http://docs.hylang.org/en/stable/language/api.html#deftag
gt@gt-ThinkPad-X230:~$ hy --spy
hy unknown using CPython(default) 3.6.8 on Linux
=> (deftag ♣ [expr] `[~expr ~expr])
from hy…
I have a Python script (as entry point), a Hy library (simply add two columns) and an input data file:
$ cat add_cols/app.py
import hy
import sys
from mylib import add2col
def main():
inp = sys.argv[1]
out = sys.argv[2]
print(f'read…