Good day!
I need some advice in more pythonic approach in get-min-distance function, which should return a pair with minimal distance value. Let`s suppose I have two functions (see bellow). Function get-dstance gets two arguments and return some distance value between objects. Function get-min-distance accepts a list of tuples (object pairs) and return a tuple (pair) with a minimal distance between two objects.
def get_distance(d1, d2):
...
...
return distance
def get_min_distance(dot_pairs):
d_list = []
for obj1, obj2 in dot_pairs:
d_list.append(get_distance(obj1, obj2))
return dot_pairs[d_list.index(min(d_list))]
I'm trying 'to play' with tuple unpacking, but have no enough practice.
d_list = list(map(get_distance, dot_pairs))
So, how to unpack circle_pairs tuple in this case?
Created at: 2015/09/05 13:05; Updated at: 2015/09/06 10:52