def transferClosestPath(oldOrderedLocation, remainingPaths, skein):
 closestDistance = 9.876543219876543e+17
 closestPath = None
 oldOrderedLocationComplex = oldOrderedLocation.dropAxis()
 for remainingPath in remainingPaths:
  distance = min(abs((oldOrderedLocationComplex - remainingPath[0])), abs((oldOrderedLocationComplex - remainingPath[(-1)])))
  if (distance < closestDistance):
   closestDistance = distance
   closestPath = remainingPath
 remainingPaths.remove(closestPath)
 skein.addGcodeFromThreadZ(closestPath, oldOrderedLocation.z)
 oldOrderedLocation.x = closestPath[(-1)].real
 oldOrderedLocation.y = closestPath[(-1)].imag

def transferClosestPath ( oldOrderedLocation , remainingPaths , skein ) : closestDistance = 9.876543219876543e+17 closestPath = None oldOrderedLocationComplex = oldOrderedLocation . dropAxis ( ) for remainingPath in remainingPaths : distance = min ( abs ( ( oldOrderedLocationComplex - remainingPath [ 0 ] ) ) , abs ( ( oldOrderedLocationComplex - remainingPath [ ( - 1 ) ] ) ) ) if ( distance < closestDistance ) : closestDistance = distance closestPath = remainingPath remainingPaths . remove ( closestPath ) skein . addGcodeFromThreadZ ( closestPath , oldOrderedLocation . z ) oldOrderedLocation . x = closestPath [ ( - 1 ) ] . real oldOrderedLocation . y = closestPath [ ( - 1 ) ] . imag
transfer the closest remaining path .