← Back to team overview

sikuli-driver team mailing list archive

[Question #226433]: swapping values in a list while looping through it.

 

New question #226433 on Sikuli:
https://answers.launchpad.net/sikuli/+question/226433

Hi guys,

I have a list
List=[a,b,c,d,e,f,g,h]

and i want to swap values in turn:
eg:

1.st modification = [b,a,c,d,e,f,g,h]
2nd modification=[a,c,b,d,e,f,g,h]
3rd modification =[a,b,d,c,e,f,g,h]
etc...

ideally I would actually like to create a new list that is:
new_List=[[b,a,c,d,e,f,g,h],[a,c,b,d,e,f,g,h],[a,b,d,c,e,f,g,h]]

I am using the following method to swap them:

Temp=List[1]
List1=List[2]
List[2]=Temp

which works fine, however when I loop through the list it doesn't revert back to the original list since the values have now been swapped. Effectively it continues to swap the already swapped list. (I think the solution might lie in shallow copy versus deep copy, i tried using a 'placeholder' for the list with placeholder=list[:], but I can't figure it out. Any suggestions?

Thank you for the help, I am slowly (very very slowly) getting the hang of things
 




-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.