Say I want to implement a simple database in Python. I do this by creating a class
class myStruct():
def __init__(self,name,salary,doB,title):
self.name=name
self.salary=salary
self.doB=doB
self.title=title
Now, I want to create objects of that class. But I want users to input all the variables themselves for each object, and the name of the object would be the user inputted name. I saw some other StackOverflow pages describing something like this, such as this link how to dynamically create an instance of a class in python? but that had to do with a classes imported from another module, and I didn't understand klass=global()["class_name"]. I don't understand how to link from user inputted string to use global().
Again, the idea is even the name of every object of class myStruct is typed in by the user, along with all the other fields for that object. How would I do this?
EDIT: I don't think some people understood what I was trying to do. The point is not to write out
instance=MyStruct(name,salary,doB,title)
in my code but instead, to have a function that creates an instance that's named after whatever user inputted for name. so it would be something like
name=input('Enter your name')
'%s' %name=MyStruct(name)
Do you get it? The name is substituted in.