[capi-sig] How to inspect module objects.
Guillaume Yziquel
guillaume.yziquel at citycable.ch
Sun Feb 14 14:44:42 CET 2010
Hello.
I'm currently reworking the existing software embedding Python (v2.5 for
now) into Objective Caml.
You can already do some trivial things with it:
> yziquel at seldon:~$ ocaml
> Objective Caml version 3.11.1
>
> # #use "topfind";;
> - : unit = ()
> Findlib has been successfully loaded. Additional directives:
> #require "package";; to load a package
> #list;; to list the available packages
> #camlp4o;; to load camlp4 (standard syntax)
> #camlp4r;; to load camlp4 (revised syntax)
> #predicates "p,q,...";; to set these predicates
> Topfind.reset();; to force that packages will be reloaded
> #thread;; to enable threads
>
> - : unit = ()
> # #require "python.interpreter";;
> /usr/lib/ocaml/python: added to search path
> /usr/lib/ocaml/python/python.cma: loaded
> /usr/lib/ocaml/python/oCamlPython.cmo: loaded
> # let q = Python.Module.import "dolfin";;
> val q : Python.obj = <abstr>
> # let w = Python.Module.import "modulethatdoesnotexist";;
> Exception: Python.Exception.Python_failure <abstr>.
> #
So it catches exceptions when trying to import a module that does not
exist, and it succeeds when importing dolfin, a module that does exist
on my box.
But then I'd like to inspect the contet of this module. So, here's my
question: How do you access the content of this module, or the content
of the python object, preferably with the C API.
All apologies if these questions seem trivial to you, but I'm quite new
to python and its internals. Pointers to relevant (tutorial?)
documentation are appreciated.
All the best,
--
Guillaume Yziquel
http://yziquel.homelinux.org/
More information about the capi-sig
mailing list