So I'm writing a script which will create several instances of User() class. I want each instance to be named after the login name of a user. I don't know beforehand how many users the script will have to create or how they are named. Right now I've created a dictionary of usernames as keys and objects themselves as values. It works, but is very unwieldy, because every time I need to access a value from within an object I have to do something like dict-user[x].value. Is there a way of automatically naming objects from variable names. So for example if I know that var1=jsmith. Can I somehow do var1=User(). This obviously won't work because I tried this. It'll just create var1 of type User.
My second question is how can I check if object is a member of a class. so let's say I create a=User(), b=User()... Can I do something similar to if x.Users()==TRUE: print "user already created" Right now I'm doing this using try-except which works but I'm looking for something cleaner. thanks for all the replies. -- http://mail.python.org/mailman/listinfo/python-list