Importing fails when using the following form:
But is fine with:
(import '(flask Flask))
This means I can't get at the actual module object, only the specified members.
Import here conforms to the rather limited spec of Clojure's import. Instead, look into using require: https://github.com/halgari/clojure-py/wiki/Python-imports-vs-Clojure-Requires
Unlike clojure-jvm, require on clojure-py works for both clojure and python modules.
Yes, that's true. However, there's no reason that import cannot work as it does in clojure. The same is true for use, which doesn't seem to be implemented.
Also, there seems to be no way to avoid namespace pollution. In jvm clojure, (require 'noir.core) means that I can access the objects in noir.core only by prefixing noir.core/ to them, whereas in py clojure it would add all the objects to the current namespace.
I've bumped into the namespace pollution too. At this point I've just used the workaround (:require [foo :only ]).
(:require [foo :only ])
fixes issue #65...caused the tests to fail. Fixed the tests
fix for issue #65
2nd commit is for issue #68.
This should fix the pollution issue. I'll look at the other issues (import and use).
Under Clojure, records are not pulled into your namespace by using use or require, they need import because they are full fledged Java classes.
It's another restriction I think should be dropped.
Can we drop import since it only serves for interop under clojure-jvm and serves no purpose in clojure-py?
It would also probably be less confusing for Pythonistas not to have an import statement that doesn't quite work like Python's.
Dropping import completely is probably the best idea. IIRC ClojureScript doesn't implement import.
If we're going to do this, it'd be worth putting in the readme alongside the note about the .- reader macro. Import kinda makes sense if you expect python-clojurepy interop to be similar to java-clojure, and it's worth telling newcomers to the project that it's different.
Back on the issue of import: right now require and refer can "intern" non-Vars in a namespace:
user=> (require 'numbers)
user=> (refer 'numbers)
#<abc.ABCMeta object at 0x2032ec0>
Perhaps only import should be allowed to do that, and refer would have to wrap python objects into vars before interning them?