Re: Worthwhile to reverse a dictionary

2006-01-07 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote: > crc <[EMAIL PROTECTED]> writes: > > I assume your talking about building a new dictionary with the key and > > value pair switched. I have seen no built in function to do this but I > > have found a way to create another dictionary that is the inverse of > >

Re: Worthwhile to reverse a dictionary

2006-01-04 Thread Mike Meyer
crc <[EMAIL PROTECTED]> writes: > I assume your talking about building a new dictionary with the key and > value pair switched. I have seen no built in function to do this but I > have found a way to create another dictionary that is the inverse of > the first. Note that you can't reliable "revers

Re: Worthwhile to reverse a dictionary

2006-01-04 Thread crc
I assume your talking about building a new dictionary with the key and value pair switched. I have seen no built in function to do this but I have found a way to create another dictionary that is the inverse of the first. for example you have designed a dictionary such as a={} a['one']=1 a['two'

Re: Worthwhile to reverse a dictionary

2005-12-15 Thread rudysanford
The end of what I was trying to do was encode and decode using ITA2 International Telegraph Alphabet 2, more commonly called Baudot. It uses 5 bit binary but with the use of a shift up or a shift down can utilize 2 tables of 32- one for letters one for figures. A better explanation of ITA2 here:

Re: Worthwhile to reverse a dictionary

2005-12-15 Thread Larry Bates
[EMAIL PROTECTED] wrote: > I just started messing with programming and started with Python. Part > of my first project deals with translating numerical values to letters. > I would like to be able to do the reverse as well, letters to numbers, > sort of a table for lookup and a table for reverse l

Re: Worthwhile to reverse a dictionary

2005-12-15 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > What is the difference between > > " d1 = {'A' : '1', 'B' : '2', 'C' : '3'} " > > and > > " d1 = dict(A = 1, B = 2, C = 3) " ? > > All of the dictionary examples I saw (python.org, aspn.activestate.com, > Learning Python by Lutz, among others) use d={'x' : 'y'}. >

Re: Worthwhile to reverse a dictionary

2005-12-14 Thread Mike Meyer
Erik Max Francis <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] wrote: >> What is the difference between >> " d1 = {'A' : '1', 'B' : '2', 'C' : '3'} " >> and >> " d1 = dict(A = 1, B = 2, C = 3) " ? >> All of the dictionary examples I saw (python.org, >> aspn.activestate.com, >> Learning Python b

Re: Worthwhile to reverse a dictionary

2005-12-14 Thread rudysanford
Thanks. That is exactly what I meant. In d2, A is not 'A' because it is being set to 1, whereas in d1, using A instead of 'A' means A is an undeclared variable instead of a string? -- http://mail.python.org/mailman/listinfo/python-list

Re: Worthwhile to reverse a dictionary

2005-12-14 Thread Erik Max Francis
[EMAIL PROTECTED] wrote: > What is the difference between > > " d1 = {'A' : '1', 'B' : '2', 'C' : '3'} " > > and > > " d1 = dict(A = 1, B = 2, C = 3) " ? > > All of the dictionary examples I saw (python.org, aspn.activestate.com, > Learning Python by Lutz, among others) use d={'x' : 'y'}. I

Re: Worthwhile to reverse a dictionary

2005-12-14 Thread rudysanford
What is the difference between " d1 = {'A' : '1', 'B' : '2', 'C' : '3'} " and " d1 = dict(A = 1, B = 2, C = 3) " ? All of the dictionary examples I saw (python.org, aspn.activestate.com, Learning Python by Lutz, among others) use d={'x' : 'y'}. -- http://mail.python.org/mailman/listinfo/pyt

Re: Worthwhile to reverse a dictionary

2005-12-14 Thread rudysanford
Thanks so much. That seems to have it. This is the sort of thing I had before: #!/usr/local/bin/python # make a short dictionary d1 = {'A' : '1', 'B' : '2', 'C' : '3'} for letter in d1.keys(): print letter, '\t', d1[letter] # make a space between the output of the 2 dictionaries print '\n'

Re: Worthwhile to reverse a dictionary

2005-12-14 Thread Will McGugan
[EMAIL PROTECTED] wrote: > I just started messing with programming and started with Python. Part > of my first project deals with translating numerical values to letters. > I would like to be able to do the reverse as well, letters to numbers, > sort of a table for lookup and a table for reverse l

Worthwhile to reverse a dictionary

2005-12-14 Thread rudysanford
I just started messing with programming and started with Python. Part of my first project deals with translating numerical values to letters. I would like to be able to do the reverse as well, letters to numbers, sort of a table for lookup and a table for reverse lookup. I thought that a dictiona