kachayev / fn.py

Functional programming in Python: implementation of missing features to enjoy FP
Other
3.35k stars 204 forks source link

_ only works with numbers? #72

Closed drakeguan closed 9 years ago

drakeguan commented 9 years ago
map('%d' % _, range(10))
TypeError: %d format: a number is required, not _Callable
microamp commented 9 years ago

Not really an answer to your question, but you can do this intead.

map(str, range(10))
Digenis commented 9 years ago

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()