I have trying to figure out how best to compare two tuples and return the values that do not match (for PS3d). Any suggestions?
My suggestion is to work with lists and convert it to a tuple when you need it, or vice versa. This is for two reasons. First, lists are mutable and, therefore, if you need to change things around then you can do so with lists but not with tuples. Second, more operations and methods are supported for lists than tuples. If I am receiving a tuple as a parameter for a function, for example, then I will convert it to a list, do whatever processing I need to do, and then convert the list(s) to tuple I necessary. For example, def someFunction(tup) t=list(tup) #do whatever processing i need against the list x=tuple(t) return x
Surely not the most efficient way, but it appears to work - http://dpaste.com/693792/
Hello, there is also list comprehensions !!! http://docs.python.org/tutorial/datastructures.html#list-comprehensions So it will be just like http://dpaste.com/hold/694119/ Voila !!!
Well den2042, doesn't that just make it too easy :) thanks!
Join our real-time social learning platform and learn together with your friends!