G
goatold
Can Python create object by name? Like
clsName = "ClassA"
aObj = createObjectByName(clsName)
clsName = "ClassA"
aObj = createObjectByName(clsName)
Can Python create object by name? Like
clsName = "ClassA"
aObj = createObjectByName(clsName)
> pass
>>> # The class is in the globals() dict.
>>> globals()["MyClass"]>>> # And also the locals() dict.
>>> locals()["MyClass"]>>> # Create an instance via the globals() dict.
>>> globals()["MyClass"]()>>> # Or via the locals() dict.
>>> locals()["MyClass"]()
Can Python create object by name? Like
clsName = "ClassA"
aObj = createObjectByName(clsName)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.