YA string interpolation and printing idea

Paul Rubin http
Sat Jan 17 03:38:13 CET 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