Hi there!
I'm currently using Cython to provide some bindings to a C api. I'm
using classes to "wrap" the various C structs, but they're VERY
repetetive to write, since many of the attribute I expose are in the form:
property title:
def __get__(self):
return self.track.title
Is there any shorthand for this? :-)
Also, I want to initialize them with a C struct pointer (they're only
ever initialized by my Cython code, not by the user themselves), is
there a better way than:
cdef class Artist:
def __init__(self):
raise TypeError("This class cannot be instantiated from Python")
cdef extern from "foo.h":
cdef Artist NEW_ARTIST "PY_NEW" (object t)
# #define PY_NEW(T) \
# (((PyTypeObject*)(T))->tp_new( \
# (PyTypeObject*)(T), __pyx_empty_tuple, NULL))
cdef Artist _create_artist(artist* artist, bool take_owner=False):
cdef Artist instance
instance = NEW_TRACK(Artist)
instance.artist = artist
instance.take_owner = take_owner
return instance
--
Kindest regards, Jørgen P. Tjernø
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev