23 Jul
2010
23 Jul
'10
10:36 p.m.
On 2010-07-23, at 16:16 , INADA Naoki wrote:
Basic problem is Python doesn't provide a way to print values of expression into str like print prints to file. 'foo{bar}baz'.format(bar=bar) is a bit bessy.
I don't understand what you find messy about either this or `'foo{}baz'.format(bar)`.
* s = print('foo', bar, 'baz', sep='', file=None) * s = print('foo', bar, 'baz', sep='', file=str) Extend print() function to return str instead of print to file.
* s = str.print('foo', bar, 'baz', sep='') Add staticmethod to str.
These forms can trivially be implemented as utility functions. And I don't see them as improvements enough to propose them for inclusion in the stdlib, but YMMV.