Re: does python could support sequence of short or int?

2006-03-30 Thread Diez B. Roggisch
momobear schrieb: hi, is there a way to let python operate on sequence of int or short? In C, we just need declare a point, then I could get the point value, just like: short* k = buffer, //k is a point to a sequence point of short. short i = *k++, but python is a dynamic language, a =

Re: does python could support sequence of short or int?

2006-03-30 Thread bruno at modulix
momobear wrote: hi, is there a way to let python operate on sequence of int or short? In C, we just need declare a point, I assume you mean a 'pointer'. then I could get the point value, just like: short* k = buffer, //k is a point to a sequence point of short. short i = *k++, but python

Re: does python could support sequence of short or int?

2006-03-30 Thread momobear
but what about buffer is not be declared in python program, it comes from a C function. and what about I want to treat a string as a short list? buffer = foobur() // a invoke from C function, it is encapsulated as a string but I want to treat it as a short list. how can I? --

Re: does python could support sequence of short or int?

2006-03-30 Thread bruno at modulix
momobear wrote: but what about buffer is not be declared in python program, it comes from a C function. and what about I want to treat a string as a short list? OT level='slightly' There are no short in Python. An integer is an integer is an integer... /OT buffer = foobur() // a invoke from

Re: does python could support sequence of short or int?

2006-03-30 Thread Fuzzyman
momobear wrote: hi, is there a way to let python operate on sequence of int or short? In C, we just need declare a point, then I could get the point value, just like: short* k = buffer, //k is a point to a sequence point of short. short i = *k++, but python is a dynamic language, a =

Re: does python could support sequence of short or int?

2006-03-30 Thread momobear
then how can I convert it to a int list? I read about struct and array, I think they are not suitable, since I don't know how long will the buffer is. I know if I write a plugins modules in C should works, but that's really upset to tell to myself there is no way in Python. --

Re: does python could support sequence of short or int?

2006-03-30 Thread Mirco Wahab
Hi momobear then how can I convert it to a int list? I read about struct and array, I think they are not suitable, since I don't know how long will the buffer is. I know if I write a plugins modules in C should works, but that's really upset to tell to myself there is no way in Python. this

Re: does python could support sequence of short or int?

2006-03-30 Thread Diez B. Roggisch
momobear wrote: then how can I convert it to a int list? I read about struct and array, I think they are not suitable, since I don't know how long will the buffer is. I know if I write a plugins modules in C should works, but that's really upset to tell to myself there is no way in Python.

Re: does python could support sequence of short or int?

2006-03-30 Thread Richard Brodie
momobear [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] then how can I convert it to a int list? I read about struct and array, I think they are not suitable, since I don't know how long will the buffer is. I know if I write a plugins modules in C should works, but that's really

Re: does python could support sequence of short or int?

2006-03-30 Thread Magnus Lycka
momobear wrote: hi, is there a way to let python operate on sequence of int or short? If you want to work with arrays of numbers, you might want to look at NumArray etc. -- http://mail.python.org/mailman/listinfo/python-list

Re: does python could support sequence of short or int?

2006-03-30 Thread Magnus Lycka
momobear wrote: but what about buffer is not be declared in python program, it comes from a C function. and what about I want to treat a string as a short list? Python is a high level language with much stronger typing than C. If you want a list of integers, use a list of integers. Strings are

Re: does python could support sequence of short or int?

2006-03-30 Thread Alex Martelli
bruno at modulix [EMAIL PROTECTED] wrote: momobear wrote: but what about buffer is not be declared in python program, it comes from a C function. and what about I want to treat a string as a short list? OT level='slightly' There are no short in Python. An integer is an integer is an

Re: does python could support sequence of short or int?

2006-03-30 Thread momobear
thanks for help. formerly I only know to use the struct like bellow: unpack('hhl', '\x00\x01\x00\x02\x00\x00\x00\x03') Great, python can work like this: l = list(struct.unpack('h'*(len(s)/2), s)) I will try to use the numarray also there are some good exensions for Python, numarray and numpy and

does python could support sequence of short or int?

2006-03-29 Thread momobear
hi, is there a way to let python operate on sequence of int or short? In C, we just need declare a point, then I could get the point value, just like: short* k = buffer, //k is a point to a sequence point of short. short i = *k++, but python is a dynamic language, a = buffer i = ? I don't know how