Re: Newbie looking for elegant solution

2015-03-25 Thread Paul Rubin
kai.pet...@gmail.com writes: > The whole file. The device polls a storage area for incoming files and > display them. If the storage area is on disk and you don't care about speed, then it's enough to convert the bit stream and write it out a character at a time. Some other posters mentioned possi

Re: Newbie looking for elegant solution

2015-03-25 Thread kai . peters
On Wednesday, 25 March 2015 18:10:00 UTC-7, Paul Rubin wrote: > nobody writes: > > I though that the bytes type is Python 3 only? If so, I cannot use it. > > In Python 2, the regular string type (str) is a byte vector, though it > is immutable. Do you send one scan line at a time to the renderin

Re: Newbie looking for elegant solution

2015-03-25 Thread Paul Rubin
kai.pet...@gmail.com writes: > I though that the bytes type is Python 3 only? If so, I cannot use it. In Python 2, the regular string type (str) is a byte vector, though it is immutable. Do you send one scan line at a time to the rendering device, or the whole file all at once, or what? Do you w

Re: Newbie looking for elegant solution

2015-03-25 Thread kai . peters
On Tuesday, 24 March 2015 20:14:06 UTC-7, otaksoft...@gmail.com wrote: > I have a list containing 9600 integer elements - each integer is either 0 or > 1. > > Starting at the front of the list, I need to combine 8 list elements into 1 > by treating them as if they were bits of one byte with 1 a

Re: Newbie looking for elegant solution

2015-03-25 Thread Irmen de Jong
On 26-3-2015 0:14, kai.pet...@gmail.com wrote: > On Tuesday, 24 March 2015 20:14:06 UTC-7, otaksoft...@gmail.com wrote: >> I have a list containing 9600 integer elements - each integer is either 0 or >> 1. >> >> Starting at the front of the list, I need to combine 8 list elements into 1 >> by tr

Re: Newbie looking for elegant solution

2015-03-25 Thread Paul Rubin
kai.pet...@gmail.com writes: > im.getdata() => sequence > Returns the contents of an image as a sequence object containing pixel > values. The sequence object is flattened, so that values for line one > follow directly after the values of line zero, and so on. And this is a list of 1's and 0's, I

Re: Newbie looking for elegant solution

2015-03-25 Thread kai . peters
On Tuesday, 24 March 2015 20:14:06 UTC-7, otaksoft...@gmail.com wrote: > I have a list containing 9600 integer elements - each integer is either 0 or > 1. > > Starting at the front of the list, I need to combine 8 list elements into 1 > by treating them as if they were bits of one byte with 1 a

Re: Newbie looking for elegant solution

2015-03-25 Thread Travis Griggs
> On Mar 24, 2015, at 8:28 PM, Chris Angelico wrote: > > On Wed, Mar 25, 2015 at 2:13 PM, wrote: >> I have a list containing 9600 integer elements - each integer is either 0 or >> 1. >> >> Starting at the front of the list, I need to combine 8 list elements into 1 >> by treating them as if

Re: Newbie looking for elegant solution

2015-03-24 Thread Rustom Mody
On Wednesday, March 25, 2015 at 11:23:08 AM UTC+5:30, Paul Rubin wrote: > kai.peters writes > > 1 bit images of a size of 1024 x 1280 need to be processed this way, > > so 1310720 list elements. Also needs to be 2.7 only. > > Where are these lists going to come from? Files? Process the file > d

Re: Newbie looking for elegant solution

2015-03-24 Thread Dave Farrance
otaksoftspamt...@gmail.com wrote: >I have a list containing 9600 integer elements - each integer is either 0 or 1. >Starting at the front of the list, I need to combine 8 list elements into 1 by >treating them as if they were bits of one byte with 1 and 0 denoting bit >on/off (the 8th element wo

Re: Newbie looking for elegant solution

2015-03-24 Thread Paul Rubin
kai.pet...@gmail.com writes: > 1 bit images of a size of 1024 x 1280 need to be processed this way, > so 1310720 list elements. Also needs to be 2.7 only. Where are these lists going to come from? Files? Process the file differently, probably. Use generators instead of lists, maybe. Or process

Re: Newbie looking for elegant solution

2015-03-24 Thread Steven D'Aprano
On Wednesday 25 March 2015 14:13, otaksoftspamt...@gmail.com wrote: > I have a list containing 9600 integer elements - each integer is either 0 > or 1. > > Starting at the front of the list, I need to combine 8 list elements into > 1 by treating them as if they were bits of one byte with 1 and 0

Re: Newbie looking for elegant solution

2015-03-24 Thread Ben Finney
Chris Angelico writes: > Of course, this does mean installing numpy. It is crushing the nut > with the triphammer - an absurd extravagance of energy, but the nut is > effectively crushed all the same. It also has the advantage that it hopefully won't be acceptable for a homework assignment. Whe

Re: Newbie looking for elegant solution

2015-03-24 Thread Chris Angelico
On Wed, Mar 25, 2015 at 3:46 PM, wrote: > Now I have just read the latest spec and speed/memory may become issues: > > 1 bit images of a size of 1024 x 1280 need to be processed this way, so > 1310720 list elements. Also needs to be 2.7 only. > > Any recommendations? 2.7 only? Then my solution w

Re: Newbie looking for elegant solution

2015-03-24 Thread kai . peters
On Tuesday, 24 March 2015 21:20:11 UTC-7, Chris Angelico wrote: > On Wed, Mar 25, 2015 at 3:04 PM, Paul Rubin wrote: > > This works for me in Python 2.7 but I think > > Python 3 gratuitously broke tuple unpacking so it won't work there: > > > >

Re: Newbie looking for elegant solution

2015-03-24 Thread kai . peters
On Tuesday, 24 March 2015 21:04:37 UTC-7, Paul Rubin wrote: > nobody writes: > > I have a list containing 9600 integer elements - each integer is > > either 0 or 1. > > Is that a homework problem? This works for me in Python 2.7 but I think > Python 3 gratuitously broke tuple unpacking so it won

Re: Newbie looking for elegant solution

2015-03-24 Thread Chris Angelico
On Wed, Mar 25, 2015 at 3:04 PM, Paul Rubin wrote: > This works for me in Python 2.7 but I think > Python 3 gratuitously broke tuple unpacking so it won't work there: > > > > from itertools import count, groupby > old = [0, 0, 0, 1,

Re: Newbie looking for elegant solution

2015-03-24 Thread Paul Rubin
otaksoftspamt...@gmail.com writes: > I have a list containing 9600 integer elements - each integer is > either 0 or 1. Is that a homework problem? This works for me in Python 2.7 but I think Python 3 gratuitously broke tuple unpacking so it won't work there: =

Re: Newbie looking for elegant solution

2015-03-24 Thread otaksoftspamtrap
On Tuesday, March 24, 2015 at 8:29:24 PM UTC-7, Chris Angelico wrote: > On Wed, Mar 25, 2015 at 2:13 PM, wrote: > > I have a list containing 9600 integer elements - each integer is either 0 > > or 1. > > > > Starting at the front of the list, I need to combine 8 list elements into 1 > > by trea

Re: Newbie looking for elegant solution

2015-03-24 Thread Chris Angelico
On Wed, Mar 25, 2015 at 2:13 PM, wrote: > I have a list containing 9600 integer elements - each integer is either 0 or > 1. > > Starting at the front of the list, I need to combine 8 list elements into 1 > by treating them as if they were bits of one byte with 1 and 0 denoting bit > on/off (th

Newbie looking for elegant solution

2015-03-24 Thread otaksoftspamtrap
I have a list containing 9600 integer elements - each integer is either 0 or 1. Starting at the front of the list, I need to combine 8 list elements into 1 by treating them as if they were bits of one byte with 1 and 0 denoting bit on/off (the 8th element would be the rightmost bit of the first