Re: Python String Substitution

2006-01-27 Thread Steven D'Aprano
On Fri, 27 Jan 2006 15:54:30 -0800, Murali wrote: > No. I dont have a real life example. I was explaining % substitution to > somebody and realized that I have only used it in the form where the > keys are strings. Was wondering if there is some special syntax already > part of python with which I

Re: Python String Substitution

2006-01-27 Thread Murali
No. I dont have a real life example. I was explaining % substitution to somebody and realized that I have only used it in the form where the keys are strings. Was wondering if there is some special syntax already part of python with which I can lookup the dictionary using a tuple as a key. - Mural

Re: Python String Substitution

2006-01-27 Thread Bengt Richter
On 26 Jan 2006 15:40:47 -0800, "Murali" <[EMAIL PROTECTED]> wrote: >In Python, dictionaries can have any hashable value as a string. In >particular I can say > >d = {} >d[(1,2)] = "Right" >d["(1,2)"] = "Wrong" >d["key"] = "test" > >In order to print "test" using % substitution I can say > >print "

Re: Python String Substitution

2006-01-26 Thread John Bauman
"Murali" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > In Python, dictionaries can have any hashable value as a string. In > particular I can say > > d = {} > d[(1,2)] = "Right" > d["(1,2)"] = "Wrong" > d["key"] = "test" > > In order to print "test" using % substitution I can say

Re: Python String Substitution

2006-01-26 Thread Steven D'Aprano
On Thu, 26 Jan 2006 15:40:47 -0800, Murali wrote: > In Python, dictionaries can have any hashable value as a string. No. Dictionaries can have any hashable value as a KEY. They are not automatically converted to strings. > In particular I can say > > d = {} > d[(1,2)] = "Right" > d["(1,2)"] = "