create instances of a class in a for loop

Solutions on MaxInterview for create instances of a class in a for loop by the best coders in the world

showing results for - "create instances of a class in a for loop"
Andrea
24 Jun 2016
1objs = [MyClass() for i in range(10)]
2for obj in objs:
3    other_object.add(obj)
4
5objs[0].do_sth()