1 Upvote
Dynamically Create Classes with Python
class DynamicClass(): def __init__(self): value = 0 num_classes = 5 dynamic_class = [DynamicClass() for i in range(num_classes)] for i in range(num_classes): dynamic_class[i].class_number = i print(dynamic_class[2].class_number)
By detro - Last Updated April 7, 2022, 10:44 a.m.
COMMENTS
RELATED SNIPPETS
3
Python Class Example Using __init__ and __repr__
Python
General Python
2
Using a Python Decorator to Print Memory Usage of a DataFrame
Python
General Python
2
2
2
2
2
2
2
2
Find Snippets by Language
Find Snippets by Use