So I have a function that can take any number of lists as arguments. With each list, I want to initiate a class object. How do I unwrap the list so I can pass it straight in to the object creation?
list_of_routes = []
class Rope_route():
def __init__(self, setter, color, grade):
self.setter = setter
self.color = color
self.grade = grade
def set_route(*args)
#each arg should be [setter, color, grade]
for item in args
list_of_routes.append(Rope_route(item))
set_route(['jimmy','green','v1'],['jonny','blue','v0'])
Is there a better way to solve this than by doing the following?
def __init__(self, args_as_list)
self.setter = args_as_list[0]
self.color = args_as_list[1]
self.grade = args_as_list[2]