Quantcast
Channel: Tuples as function parameters - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Tuples as function parameters

$
0
0

I have this old code that I'm trying to convert from 2.7 to 3 but I cant figure out how to pass some tuple parameters.

Here is the code:

def make_dis(self):    if self.ds == "SEP_EU":        def metric((x, y), (a, b)): # <- Error here (Invalid syntax)            return math.sqrt((x - a) ** 2 + (y - b) ** 2)    else:        def metric(a, b):            return 0    self.n_dist = [[metric(self.n_coord[i], self.n_coord[j]) for i in range(self.dim)] for j in range(self.dim)]    return self

How can I make metric function accept those parameters?Thanks for your help.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images