[Nexus] Nexus with python on windows

Darren Dale darren.dale at cornell.edu
Tue Nov 20 15:30:09 GMT 2007


On Monday 19 November 2007 04:13:33 pm Jon Wright wrote:
> Hi Darren, Andy;
>
> There is a nice video introduction to PyTables at:
>
> http://www.carabos.com/videos/pytables-1-intro
>
> I'd be curious as to how hard it is to write a Nexus compliant hdf file
> using PyTables.
>
>  > I know he has grappled with Python and Nexus in the past
>
> Hmm... clearly not an expert, I lost that fight. Freddie did compile the
> python bindings for us a while back. Having gotten the executables I
> tried again just now and am not able to get past the testcase which
>
> comes with them:
>   >>> import nxpython
>   >>> h = nxpython.nx_open("nxpython_test.nxs", nxpython.NXACC_CREATE)
>   >>> type(h)
>
>   <type 'PySwigObject'>
>
>   >>> help(h)
>
>   [...]
>
>   >>> help(nxpython)
>
>   [...]
>
>   >>> for i in dir(nxpython):print type(getattr(nxpython,i)),i
>
>   [...]
>
>   # start of C example:
>   >>> nxpython.nx_putattr (h , "user_name", "Joe Bloggs")
>
>   Traceback (most recent call last):
>     File "<stdin>", line 1, in ?
>   TypeError: in method 'nx_putattr', argument 3 of type 'void *'
>
> Any suggestions?
[...]
> Wrapping  func(..., void *p, size_of_p, type_of_p)  is likely to be
> interesting.

I don't have much experience with C/C++ or swig, but this seems like it might 
be relevant if it is still applicable, from 
http://www.swig.org/papers/PyTutorial97/PyTutorial97.pdf:

"SWIG does not support pointers to C++ member functions. This is because such 
pointers can not be properly cast to a pointer of type 'void *' (the type 
that SWIG uses internally)"

Also this: http://www.swig.org/Doc1.3/SWIGPlus.html#SWIGPlus_nn21

Darren


More information about the NeXus mailing list