[Pyrex] Assign C object to a cdeffed variable of a class

Stefano Esposito stefano.esposito87 at gmail.com
Sat Sep 8 20:24:35 CEST 2007


On Sat, 08 Sep 2007 10:05:44 -0700
Lenard Lindstrom <len-l at telus.net> wrote:

[snip]
> But why? Is it not more sensible for package_new_from_file to return a 
> Package object?

Indeed i was returning the pypkg, but i haven't showed it on the list 'cause it was after the error :)

> def package_new_from_file(filename):
>     cdef Package pypkg
>     cdef pmpkg_t *pkg
>     alpm_pkg_load(filename, &pkg)
>     pypkg = Package()
>     pypkg.pkg = pkg
>     return package

This worked, thanks :)

> Better still, if alpm_pkg_load is the only way to create a pmpkp_t then 
> call it from the Package constructor.

Nope, it's not the only way.

Thanks for the help, anyway... could you point me to a link which explains what is the exact meaning of cdeffing a pyrex defined class? :)

-- 
Stefano Esposito <stefano.esposito87 at gmail.com>



More information about the Pyrex mailing list