Guillaume Yziquel wrote:
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@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.
Some pointers:
http://docs.python.org/c-api/module.html#PyModule_GetDict http://docs.python.org/c-api/dict.html
The C-API documentation should help you dig further into Python objects:
http://docs.python.org/c-api/index.html
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Feb 14 2010)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/