ACCEPTED: PEP 285
Neal Norwitz
neal at metaslash.com
Thu Apr 4 20:32:11 EST 2002
James Logajan wrote:
>
> Eri Ma Franci <max at alcyone.com> wrote:
> > Could you find something better to complain about?
>
> Then I'd like to complain that neither you nor Guid va Rossu addressed the
> question I asked in my previous message concerning bools as keys. If a bool
> is to be treated as an int sometimes and sometimes not, I don't recall
> seeing anything about whether it will be treated as an int as a dictionary
> key. If I do:
>
> x = ["is", "are"]
> y = {0: "", 1:"s"}
>
> for n in range(3):
> print "There %s %d item%s." % (x[n <> 1], n, y[n <> 1])
>
> Will the behavior be backword compatible and equivalent or not? Simple
> question I assume; waiting for an answer.
You could try it yourself, but it looks the same to me.
Python 2.1.1 (#1, Aug 13 2001, 19:37:40)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-96)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> x = ["is", "are"]
>>> y = {0: "", 1:"s"}
>>>
>>> for n in range(3):
... print "There %s %d item%s." % (x[n <> 1], n, y[n <> 1])
...
There are 0 items.
There is 1 item.
There are 2 items.
******************
Python 2.3a0 (#238, Apr 4 2002, 20:30:33)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x = ["is", "are"]
>>> y = {0: "", 1:"s"}
>>>
>>> for n in range(3):
... print "There %s %d item%s." % (x[n <> 1], n, y[n <> 1])
...
There are 0 items.
There is 1 item.
There are 2 items.
More information about the Python-list
mailing list