Please help me make sence of this line


(SidV) #1

I’m eager to learn Python at the moment and still in the process to make sense of python syntax.
I came across a peace of code that measures the length of a curve. Inside a for loop, i found a line like:

for i in edges:
variable1, variable2 = i.vertices

I cant make sense of it. Please help.


(Secrop) #2

somevar=[(‘value1’), (‘value2’)]
var1, var2 = somevar

print(var1)
>>>‘value1’

print(var2)
>>>‘value2’

In that case, as an edge has two vertices, and i.vertices is an array with two variables. One will be attributed to variable1, and the other to the variable2


(SidV) #3

Ah ok, this means the first variable gets the first vertice in list, the second variable gets the second and looping through a second time the vertex 3 is stored in variable 1 and vert4 in variable 2 and so on…

Thx mate, good explanation!