This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年02月08日 18:44 by umedoblock, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg152897 - (view) | Author: umedoblock (umedoblock) | Date: 2012年02月08日 18:44 | |
format() mis understaning.
please pay attention to [0], [x].
>>> d = {0: "a", "0": "A"}
>>> 'd[0] = {0[0]}'.format(d)
'd[0] = a'
>>> 'd[0] = {0["0"]}'.format(d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: '"0"'
>>> d2 = {"x": 100}
>>> 'd2[x] = {0[x]}'.format(d2)
'd2[x] = 100'
|
|||
| msg152902 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2012年02月08日 19:39 | |
This is working as defined in PEP 3101: it calls PySequence_GetItem() or PyObject_GetItem() on the value inside the brackets. There is indeed no item in d that is the string "0" (including the quotes). |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:26 | admin | set | github: 58179 |
| 2012年02月08日 19:39:34 | eric.smith | set | status: open -> closed messages: + msg152902 assignee: eric.smith resolution: not a bug stage: resolved |
| 2012年02月08日 18:45:30 | ezio.melotti | set | nosy:
+ eric.smith |
| 2012年02月08日 18:44:22 | umedoblock | create | |