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
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
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 "
"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
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)"] = "