Chrome Extension

[Python] Create a list of objects using class names

# In Python, the name of the class refers to the class instance. Consider:

class A: pass
class B: pass
class C: pass

lst = [A, B, C]

# instantiate second class
b_instance = lst[1]()
print(b_instance)
Code faster with devsheet chrome extension and increase productivity as a programmer
search code from your favorite search engine instantly.
Install Now
Was this helpful?
0 Comments
Open Code Manager We are hiring