Commit b62c01ae7d135e2f2eafbbb6f0db07e519d8c584

Authored by selurvedu
1 parent f8888f3d

Improve list generation in set_to_object()

@@ -418,8 +418,7 @@ def set_to_object(obj, path, value): @@ -418,8 +418,7 @@ def set_to_object(obj, path, value):
418 plusone = 1 if index >= 0 else 0 418 plusone = 1 if index >= 0 else 0
419 if len(obj[key]) < abs(index) + plusone: 419 if len(obj[key]) < abs(index) + plusone:
420 while not len(obj[key]) == abs(index) + plusone: 420 while not len(obj[key]) == abs(index) + plusone:
421 - extension = [None for _ in  
422 - range(abs(index) + plusone - len(obj[key]))] 421 + extension = [None] * (abs(index) + plusone - len(obj[key]))
423 if index < 0: 422 if index < 0:
424 obj[key] = extension + obj[key] 423 obj[key] = extension + obj[key]
425 else: 424 else:
@@ -441,7 +440,7 @@ def set_to_object(obj, path, value): @@ -441,7 +440,7 @@ def set_to_object(obj, path, value):
441 return obj 440 return obj
442 441
443 if not isinstance(path, STR_TYPES): 442 if not isinstance(path, STR_TYPES):
444 - raise TypeError('Path must be one of %s' % str(STR_TYPES)) 443 + raise TypeError('Path must be one of ' + str(STR_TYPES))
445 return munchify(recur(obj, path, value)) 444 return munchify(recur(obj, path, value))
446 445
447 446
Please register or login to post a comment