ctypes & strings

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sat Dec 27 15:03:13 EST 2008


En Sat, 27 Dec 2008 10:54:32 -0200, Hendrik van Rooyen  
<mail at microcorp.co.za> escribió:

> The c routine will actually break Python's normal string
> immmutability and give you back a changed ins.

...so don't do that!
If you require a mutable string to pass to C functions, use  
ctypes.create_string_buffer()

> It is in general not a good idea to change the passed string
> like I am doing - but you wanted to know how
> to pass a python string, and the outs example should get
> you going - a string is an array of characters in c...

Hmmm, I don't think posting a potentially harmful example is actually a  
good idea...

-- 
Gabriel Genellina




More information about the Python-list mailing list