On 21 Mar 2005 19:32:20 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Can i do something like this?
>
> if code == CODE1:
> data = 0x0
> While True:
> len = len - 1
> if len == -1:
> break
> buffer = data
>
> Do i need to initialze the buffe
"len" is a built-in function in Python, so you probably don't want to
use it as a variable name.
What is this C code actually trying to do? Don't try to transliterate
it; instead, read up on how lists and slicing work, and rewrite it in
Python starting from a higher level of abstraction.
One hin
> 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 u
Can i do something like this?
if code == CODE1:
data = 0x0
While True:
len = len - 1
if len == -1:
break
buffer = data
Do i need to initialze the buffer?
-Thanks,
Joe
--
http://mail.python.org/mailman/listinfo/python-list
agreed.
you might say i was trying to translate his C code "word for word",
rather than properly "pythonizing" the entire chunk of code as a whole.
--
http://mail.python.org/mailman/listinfo/python-list
On 21 Mar 2005 17:16:18 -0800, integer <[EMAIL PROTECTED]> wrote:
> you never deal directly with pointers in python.
> in your case, you need to pass a mutable object as your 'buffer'
> argument and perform operations on it such that 'buffer==data'. (for
> example, you could use a list here.)
> def
you never deal directly with pointers in python.
in your case, you need to pass a mutable object as your 'buffer'
argument and perform operations on it such that 'buffer==data'. (for
example, you could use a list here.)
def testit( buffer ):
for i in range( len ):
buffer[A+i]=data[B+i]
for
On 21 Mar 2005 15:52:44 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am trying to convert some C code into python.
> Here's the C code...
>
> typedef enum {
> CODE1 = 0x1,
> CODE2 = 0x2
> } CODE
> testit(unsigned char *buffer,
>unsigned long length,
>CODE cod