New submission from Lie Ryan <lie.1...@gmail.com>: I've been experimenting with namedtuple, it seems that string formatting doesn't recognize namedtuple as mapping.
from collections import namedtuple Nt = namedtuple('Nt', ['x', 'y']) nt = Nt(12, 32) print 'one = %(x)s, two = %(y)s' % nt # output should be: one = 12, two = 32 currently, it is possible to use nt._asdict() as a workaround, but I think it will be easier and more intuitive to be able to use namedtuple directly with string interpolation. I tried this with 2.6 and 2.7a (trunk). Haven't seen 3.0 yet. PS: Although the following works, it is not the topic of the issue: print 'one = %s, two = %s' % nt ---------- components: Library (Lib) messages: 81555 nosy: lieryan severity: normal status: open title: String Formatting with namedtuple type: feature request versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5205> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com