[Pyrex] char initialisation

John Machin sjmachin at lexicon.net
Tue Sep 27 03:57:08 CEST 2005


Fabien Cromières wrote:

>Hi,
>
>I have a small problem: I can't find how to affect value to char variables:
>For example, the classical C syntax doesn't work::
>
>cdef char c
>c='a'
>
>here, pyrex understand 'a' as a string (that is a char * ) and refuse
>to convert it to a char. Same  problem with c="a".
>For the moment, I use c='a'[0]. It works, but it is not very beautiful.
>Is there a more elegant way?
>
>  
>
Depends on your definition of "elegance" :-)
Look at this URL:
http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/version/Doc/overview.html#Basics
which contains:
"""
Character literals are written with a c prefix, for example:

c'X'
"""




More information about the Pyrex mailing list