[SciPy-user] Weave - accessing object data members?

eric jones eric at enthought.com
Tue May 27 12:19:35 EDT 2003


> Great!  This is enough for my needs, even with a bit of
> typecasting/overloading required.  All I needed was a quick way to get
at
> an arbitrary attribute from an object (whose type I know, so manual
type
> handling is not a problem in this case).

Type casting isn't necessary in some places.  For example:

>>> class bob:
...  pass
...
>>> import weave
>>> q = bob()
>>> q.a  = 1
>>> weave.inline("""
                 int aa = q.attr("a"); 
                 std::cout << aa + 1 <<  std::endl;
                 """,['q'])
2

So, when C++ can figure out the type, it'll do the casting for you.
It's only in places where the type is ambiguous that you must help it
out.

eric 





More information about the SciPy-User mailing list