Suppose I have a file foo.hy
, which looks like this:
(def friends ["Joe" "Mark" "Bob"])
And another file bar.hy
, in the same directory as foo.hy
, which looks like this:
#!/usr/bin/env hy
(import foo)
In bar.hy
, I'd like to refer to the friends
variable defined in foo.hy
. How would I do this? For example, I'd like to call print
with friends
from bar.hy
, but I'm not sure how to do this (and all my attempts don't seem to make the Hy REPL too happy).
(import foo)
(print foo.friends)
Or, if you want to import friends
into the current namespace, so you don't have to prefix it with foo.
:
(import [foo [friends]])
(print friends)