9

I'd like to use Hy, a dialect of Lisp on top of Python. However my coworkers all use Python and aren't likely to switch over to a Lisp dialect any time soon.

How can I package Hy code into a standard Python module?

Tim Martin
  • 3,618
  • 6
  • 32
  • 43
MRocklin
  • 55,641
  • 23
  • 163
  • 235

2 Answers2

10

You have three basic options.

  1. have your coworkers import hy as dg123 wrote.

  2. use a python package and import hy yourself in your packages __init __.py file. Your coworkers can then just import your modules.

  3. compile your module using hyc and deploy the .pyc file which your coworkers can import as normal python module.

Felix Benner
  • 268
  • 1
  • 7
5

Simple! After all your coworkers have done pip install hy, they can include your .hy files as regular Python modules by:

1) Importing hy:

import hy

2) Importing the name of the module as if it were Python with a .py extension:

import module_name

(where in this example, module_name would be referring to module_name.hy in the same directory as the Python code)

DJG
  • 6,413
  • 4
  • 30
  • 51