C pointers/Python
Marcin Mika
intager at gmail.com
Tue Mar 22 00:00:48 EST 2005
> Can i do something like this?
>
> if code == CODE1:
> data = 0x0
> While True:
> len = len - 1
> if len == -1:
> break
> buffer = data
certainly not!
there are many things wrong with that.
first of all, as was pointed out already: this is highly un-pythonic.
secondly, its completely wrong. if you bind 'buffer' to another object,
then you have no chance of modifying its original contents. thats why i
stated in my previous post that IF you insist on persuing the
"un-pythonic" path then your function argument 'buffer' _must_ be a
mutable object which you must operate on through its methods, but you
CANNOT modify it with: buffer=data.
doing that will only re-bind 'buffer', it will never change anything
outside the function.
More information about the Python-list
mailing list