In Python, how do I check if an instance of my class exists? -


i'm making program asks user login, , i'm wondering how can make checks if instance of username class exists. oh , please excuse sloppy , disorganized coding, i'm not @ it.

quit_login = 1 class usernames:     def __init__(self, password):         self.password = password testlogin = usernames("foo") def login_e():     = raw_input("please enter username: ")     new_pass = ""     if isinstance(a, usernames):         = usernames(new_pass)         print usernames     else:         login_pass = raw_input("what password?\n")         if login_pass == a.password:             print "hello",         else:             print "incorrect password" while quit_login != 0:     login_e() 

the missing piece collection hold usernames instances. particular scenario, want dictionary.

>>> mydict = {} >>> mydict['foo'] = 5 >>> 'foo' in mydict true >>> mydict['foo'] 5 >>> mydict.get('bar', 'nope') 'nope' >>>  

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -