it also won't work if your values are mutable (e.g.: lists), since they can't be used as keys in your mirroring dictionary.
----- Original Message ----- From: "Noah Spurrier" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 25, 2002 7:22 PM Subject: RE: How to get a key from dictionary? > > One way to do this is to simply create two dictionaries at the same time. > Each dictionary is the mirror of each other. > dict1={'aa':1, 'bb':2] > dict2={1:'aa', 2:'bb'] > Not very elegant, but it's simple. This assumes that your dictionary is one-to-one. > For example, this dictionary would not work: > dict1=['aa':1, 'bb':1] > > Yours, > Noah > > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED]]On Behalf Of A > > Sent: Monday, March 25, 2002 2:16 PM > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; > > [EMAIL PROTECTED]; [EMAIL PROTECTED] > > Subject: How to get a key from dictionary? > > > > > > Hi, > > Is there a possibility to get, from a dictionary, a key according to a > > value ? > > For example > > I have a dictionary > > > > dict={'aa':1,'bb':2} > > > > and > > dict['aa'] > > is 1 > > > > But how can I for value 1 find out key? (That is here 'aa') > > > > Thank you for help > > Ladislav > > > > > > _______________________________________________ > > ActivePython mailing list > > [EMAIL PROTECTED] > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > > _______________________________________________ > ActivePython mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ ActivePython mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs