Having difficulty with decorators - trying to get Google Cloud Functions working #2455
-
Hello Hy community! I am trying to get a Hy script to be properly translated into Python, so that Google Functions Framework will accept the code. Ultimately, I want to upload it to Google Cloud Functions. The Python code should look like the following:
Unfortunately, I can't get the decorator to create the signature properly. It ALWAYS puts a set of function parens on the end.
My source Hy code is below. I am using
Any help would be appreciated. Although a long-time lisp user, I am new to Hy. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The implicit call works the same as in Hy as in Python. You need to write Don't forget that decorators are little more than syntactic sugar for higher-order functions anyway. You can always say e.g. |
Beta Was this translation helpful? Give feedback.
The implicit call works the same as in Hy as in Python. You need to write
(defn [functions-framework.http] …)
or(defn [(. functions-framework http)] …)
in Hy to get@functions_framework.http
in Python.Don't forget that decorators are little more than syntactic sugar for higher-order functions anyway. You can always say e.g.
(setv hello (functions-framework.http (fn [request] …)))
.