_ only works with numbers?
drakeguan opened this issue · 2 comments
drakeguan commented
map('%d' % _, range(10))
TypeError: %d format: a number is required, not _Callable
microamp commented
Not really an answer to your question, but you can do this intead.
map(str, range(10))
Digenis commented
It works only for objects whose __mod__
raises NotImplemented on the right operand
or objects that don't define it at all. In both cases, objects need to have different types.
Perhaps the documentation needs a notice, asking the user to understand
what python calls the Data model in order to avoid such pitfalls
For your question, you can always pass a prepared 'format string, eg {0:d}'.format
to map()