Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

create instances of a class in a for loop

objs = [MyClass() for i in range(10)]
for obj in objs:
    other_object.add(obj)

objs[0].do_sth()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #instances #class #loop
ADD COMMENT
Topic
Name
3+7 =