3

how to print a object HyExpression as

HyExpression([
    HyExpression([
      HySymbol('/'),
      HyInteger(2)]),
    HyExpression([
      HyString('ceil')])])

as

'((/ 2) ("ceil"))'

in console ?

Xu Qinghan
  • 153
  • 1
  • 6

1 Answers1

4

ah! I have found the answer and its as follows hy_repr!

just use in .py

from hy.contrib.hy_repr import hy_repr

input_rule_list = '["?" ((/ 2) ("ceil"))]'
expr_input_list = hy.read_str(input_rule_list) #HyExpression 

#do something with this expr

print(hy_repr(expr_rule_parsed))

(cond [((get predicators "?") ) [((/ 2)) (("ceil"))]])

Cool!

Xu Qinghan
  • 153
  • 1
  • 6