I'm working on module which saved users' data onto Parse.com cloud. Using Parse.py library, I need to do this:
class Cat:
pass
cat = Cat()
cat.name = 'Alice'
cat.save()
Where Cat
is name of table in cloud.
Is it possible somehow to create class dynamically from string not having it anywhere else before?
Here is suggested, that there's module with pre-defined class.
Here eval
is also used on pre-defined class.
So, it it possible to create class dynamicallly in runtime only from string? Something like:
save_data('Alice','myclass')
def upload(cat_name, class_name):
class_name.name = cat_name
class_name.save()