Re: how do you convert and array of doubles into floats?

2006-09-15 Thread Diez B. Roggisch
>> AFAIK d and f are synonym for arrays, as python doesn't distinguish >> between these two on a type-level. And double it is in the end. > > No `array.array` is really about "C compiler types". You get C doubles in > form of Python's `float` type if you read from the `array.array` but it's > st

Re: how do you convert and array of doubles into floats?

2006-09-15 Thread SpreadTooThin
Tim Peters wrote: > [Marc 'BlackJack' Rintsch] > >> What about: > >> > >> b = array.array('f', a) > > [Diez B. Roggisch] > > AFAIK d and f are synonym for arrays, as python doesn't distinguish > > between these two on a type-level. And double it is in the end. > > While Python has no type of its o

Re: how do you convert and array of doubles into floats?

2006-09-15 Thread Tim Peters
[Marc 'BlackJack' Rintsch] >> What about: >> >> b = array.array('f', a) [Diez B. Roggisch] > AFAIK d and f are synonym for arrays, as python doesn't distinguish > between these two on a type-level. And double it is in the end. While Python has no type of its own corresponding to the native C `flo

Re: how do you convert and array of doubles into floats?

2006-09-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Diez B. Roggisch wrote: > Marc 'BlackJack' Rintsch schrieb: >> In <[EMAIL PROTECTED]>, SpreadTooThin >> wrote: >> >>> I have some code... >>> >>> import array >>> >>> a = array.array('d') >>> f = open('file.raw') >>> a.fromfile(f, 10) >>> >>> now I need to convert them int

Re: how do you convert and array of doubles into floats?

2006-09-15 Thread Diez B. Roggisch
Marc 'BlackJack' Rintsch schrieb: > In <[EMAIL PROTECTED]>, SpreadTooThin > wrote: > >> I have some code... >> >> import array >> >> a = array.array('d') >> f = open('file.raw') >> a.fromfile(f, 10) >> >> now I need to convert them into floats (32 bit...) what do i do? > > What about: > > b = ar

Re: how do you convert and array of doubles into floats?

2006-09-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, SpreadTooThin wrote: > I have some code... > > import array > > a = array.array('d') > f = open('file.raw') > a.fromfile(f, 10) > > now I need to convert them into floats (32 bit...) what do i do? What about: b = array.array('f', a) Ciao, Marc 'BlackJack' Rint

Re: how do you convert and array of doubles into floats?

2006-09-15 Thread Diez B. Roggisch
SpreadTooThin schrieb: > I have some code... > > import array > > a = array.array('d') > f = open('file.raw') > a.fromfile(f, 10) > > now I need to convert them into floats (32 bit...) what do i do? I guess module struct is your friend. Something like this: struct.pack("f" * len(a), *a) Di

how do you convert and array of doubles into floats?

2006-09-15 Thread SpreadTooThin
I have some code... import array a = array.array('d') f = open('file.raw') a.fromfile(f, 10) now I need to convert them into floats (32 bit...) what do i do? -- http://mail.python.org/mailman/listinfo/python-list