Help doing it the "python way"



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 of grid coordinates (x, y). From that list, I want to create a new list that for each coordinate, I add the coordinate just above and just below (x,y+1) and (x,y-1)

right now I am using a for loop to go through all the coordinates and then separate append statements to add the top and bottom.

is there a way to do something like: [(x,y-1), (x,y+1) for zzz in coord_list] or something along those lines?

thanks!
.



Relevant Pages

  • Re: python docs search for print
    ... When a python beginner quick searches for "print" on ... the print function doesn't even come up in the top 20 ...
    (comp.lang.python)
  • Re: Documentation suggestions
    ... "BeginnersGuide," but the first three are not warm welcomes, they are housekeeping matters about where you can take courses or how to download Python for people who don't know whether they want to or not yet, or there's one that says "examples" which will take you to the ActiveState Cookbook site so you can get really confused. ... It would be really nice if a total beginner did actually see a usable path through the web to their first working Python program. ... - get rid of the 1-7 list at the top it is very confusing and does not present information in a useful form or order. ... All of these links except the help link appear in the body text in more useful form. ...
    (comp.lang.python)
  • Re: python docs search for print
    ... When a python beginner quick searches for "print" on ... The print statement isn't even listed as far as I can tell. ... of useful third-party links. ...
    (comp.lang.python)
  • Re: Can you please help to make decision?
    ... python: my_str = str ... That is not really the issue, remember I was talking to a beginner. ... I don't think ruby is ever going to be readable in that way. ... I doubt that Ruby's learning curve is flatter. ...
    (comp.lang.ruby)
  • Re: Can I inherit member variables?
    ... Actually, in Python, you can. ... but trying to explain that to a beginner would just make things ... inheritance is a very overrated concept IMHO ... I really think that insisting on implementation inheritance is the wrong ...
    (comp.lang.python)