Python String Immutability Broken!
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Aug 25 11:42:40 EDT 2008
En Mon, 25 Aug 2008 17:31:22 -0300, Hendrik van Rooyen <mail at microcorp.co.za> escribió:
> Patrick Maupin <pmau....ail.com> wrote:
>
>>But let me get this straight: Are you just complaining that if you
>>pass a string to an arbitrary C function using ctypes, that that
>>arbitrary function can modify the string?
>
> Actually, I am not complaining - I am asking for advice on the side
> effects of what I am doing, which is replacing a bunch of bits
> in what is essentially an output bit field with the corresponding
> input bits at the same addresses read back from a simulated i/o
> bus structure. And I would also like to know if there is a better
> way of doing this.
To avoid altering the equilibrium of the whole universe, use ctypes.create_string_buffer:
http://python.net/crew/theller/ctypes/tutorial.html#fundamental-data-types
--
Gabriel Genellina
More information about the Python-list
mailing list