[Pyrex] char * from python

Brent Pedersen bpederse at gmail.com
Fri Dec 1 18:35:30 UTC 2006


hi, i've just been tinkering with pyrex, trying to do this (below).
but it segfaults on the sscanf line in pyscanf.
what am i doing wrong? is this more involved than my naive approach?

thanks,
-brent

##############################
# pyscanf.pyx

cdef extern from "stdio.h":
    int sscanf (char *,char *,...)

def pyscanf(char * str):
    cdef char * q
    cdef char * s
    cdef int my_int
    cdef float my_float
    sscanf(str,"%s %s %i %f",q,s,&my_int,&my_float)
    return [q,s,my_int,my_float]


####### run with ###########
from pyscanf import pyscanf
print pyscanf("asdf asdf 123 12.22")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20061201/0ab61a6b/attachment.html 


More information about the Pyrex mailing list