[Tutor] Best way to store and access a fixed coordinate list
David Crisp
david.crisp at gmail.com
Fri Aug 19 12:53:12 CEST 2011
Dont worry! I solved this. I had a brain fade earlier today when I was
working on the problem and it wasnt untill this evening when I got
home and relaxed that what I was after came to mind.
The following code example does the basics of what I was trying to do.
Its pretty damn simple. so i was deep in the forest and couldnt see
the tree!
x = {(1,2),(4,4),(4,6),(3,5)}
for eachitem in x:
print eachitem,eachitem[0], eachitem[1]
Regards,
On Fri, Aug 19, 2011 at 1:14 PM, David Crisp <david.crisp at gmail.com> wrote:
> Hello,
>
> I have a large grid of numbers 100 * 100
>
> I then randomly select an X and Y to act as a "centre" point.
>
> I have a list of numbers which are coordinate offsets which are then
> applied to the centre point as per:
>
> X = (-2,2),(-4,2),(4,2),(2,2) (The list is about 200 coordinate pairs long)
>
> The idea is that I iterate through the list of coordinates in X and do
> the following:
>
> if (Centrepoint plus x and y offset) = something then something else.
>
> So, what is the best way of storeing this within a script.
>
> What is the best way of accessing it then later so I can break out the
> first and second number in the coordinate pair and actually use them
> in a calculation.
>
> suggestions are welcome. I have been focused on this for a few hours
> now and I think i cant see the trees for the forest (of the problem)
>
> Regards,
> David
>
More information about the Tutor
mailing list