Re: Help doing it the "python way"

2012-05-29 Thread Arnaud Delobelle
On 24 May 2012 21:22, Scott Siegler wrote: > Hello, > > I am an experienced programmer but a beginner to python.  As such, I can > figure out a way to code most algorithms using more "C" style syntax. > > I am doing something now that I am sure is a more python way but i can't > quite get it rig

Re: Help doing it the "python way"

2012-05-29 Thread Jan Kuiken
On 5/24/12 22:22 , Scott Siegler wrote: I am an experienced programmer but a beginner to python. As such, I can figure out a way to code most algorithms using more "C" style syntax. I am doing something now that I am sure is a more python way but i can't quite get it right. I was hoping som

Re: Help doing it the "python way"

2012-05-26 Thread Nobody
On Thu, 24 May 2012 13:22:43 -0700, Scott Siegler wrote: > is there a way to do something like: > [(x,y-1), (x,y+1) for zzz in coord_list] > or something along those lines? [(xx,yy) for x, y in coord_list for xx, yy in [(x,y-1),(x,y+1)]] or: [(x,yy) for x, y in coord_list for yy i

Re: Help doing it the "python way"

2012-05-25 Thread Ian Kelly
On Thu, May 24, 2012 at 5:12 PM, Emile van Sebille wrote: > On 5/24/2012 2:30 PM Paul Rubin said... > >> Paul Rubin  writes: >>> >>>     new_list = chain( ((x,y-1), (x,y+1)) for x,y in coord_list ) >> >> >> Sorry: >> >>    new_list = list(chain( ((x,y-1), (x,y+1)) for x,y in coord_list)) > > > >>>

Re: Help doing it the "python way"

2012-05-24 Thread Terry Reedy
On 5/24/2012 4:53 PM, Duncan Booth wrote: Scott Siegler wrote: Hello, I am an experienced programmer but a beginner to python. As such, I can figure out a way to code most algorithms using more "C" style syntax. Hi, welcome to Python. I came here from C also. I am doing something now tha

Re: Help doing it the "python way"

2012-05-24 Thread Emile van Sebille
On 5/24/2012 2:30 PM Paul Rubin said... Paul Rubin writes: new_list = chain( ((x,y-1), (x,y+1)) for x,y in coord_list ) Sorry: new_list = list(chain( ((x,y-1), (x,y+1)) for x,y in coord_list)) >>> from itertools import chain >>> coord_list = zip(range(20,30),range(30,40)) >>> a =

Re: Help doing it the "python way"

2012-05-24 Thread Paul Rubin
Paul Rubin writes: > new_list = chain( ((x,y-1), (x,y+1)) for x,y in coord_list ) Sorry: new_list = list(chain( ((x,y-1), (x,y+1)) for x,y in coord_list)) -- http://mail.python.org/mailman/listinfo/python-list

Re: Help doing it the "python way"

2012-05-24 Thread Dave Angel
On 05/24/2012 04:22 PM, Scott Siegler wrote: > Hello, > > I am an experienced programmer but a beginner to python. As such, I can > figure out a way to code most algorithms using more "C" style syntax. > > I am doing something now that I am sure is a more python way but i can't > quite get it ri

Re: Help doing it the "python way"

2012-05-24 Thread Paul Rubin
Scott Siegler writes: > is there a way to do something like: >[(x,y-1), (x,y+1) for zzz in coord_list] > or something along those lines? You should read the docs of the itertools module on general principles, since they are very enlightening in many ways. Your particular problem can be hand

Re: Help doing it the "python way"

2012-05-24 Thread Duncan Booth
Scott Siegler wrote: > Hello, > > I am an experienced programmer but a beginner to python. As such, I > can figure out a way to code most algorithms using more "C" style > syntax. > > I am doing something now that I am sure is a more python way but i > can't quite get it right. I was hoping

Help doing it the "python way"

2012-05-24 Thread Scott Siegler
Hello, I am an experienced programmer but a beginner to python. As such, I can figure out a way to code most algorithms using more "C" style syntax. I am doing something now that I am sure is a more python way but i can't quite get it right. I was hoping someone might help. So I have a list