Are there sprintf in Python???
Neil Cerutti
horpner at yahoo.com
Tue Jan 23 11:21:39 EST 2007
On 2007-01-22, questions? <universal_used at hotmail.com> wrote:
> Are there any sprintf in Python?
> I know you can print to files(or redefine sys.stout) and later open the
> file content.
>
> Are there similar function to sprintf in C?
No, but you can compose a similar function very easily.
def sprintf(format, *objects):
return format % tuple(objects)
Since strings are immutable it's not convenient to provide a
pass-out parameter as in C. If you want to check for errors
you'll have to catch the exceptions, rather than inspect the
return value as you can in C.
--
Neil Cerutti
Symphonies of the Romantic era were a lot longer in length. --Music Lit Essay
--
Posted via a free Usenet account from http://www.teranews.com
More information about the Python-list
mailing list