YA string interpolation and printing idea

Paul Rubin http
Fri Jan 16 21:38:13 EST 2004


How about adding a string interpolation method and a some print
methods to strings.

'hello world'.print([fd])  => same as "print 'hello world'".  With optional
                              fd arg, print to file object
'hello world'.write([fd])  => same as "sys.stdout.write('hello world')"
                              i.e. print with no trailing newline
'hello $name'.interp()  => like "'hello %s'%name"
'hello $name'.fprint([fd])  => like ('hello %s'%name).print([fd])
'hello $name'.fwrite([fd])  => like ('hello %s'%name).write([fd])



More information about the Python-list mailing list