Two newbie questions

Moshe Zadka moshez at
Thu Nov 9 15:46:46 CET 2000

[Fred Clare]
>   1.)  Is there a Python equivalent to the C function "sprintf"?
>        That is, I would like to do a formatted print and save
>        the result in a Python string.

The "%" operator, as in "%s %d" % ("hello", 5)

>   2.)  What is an efficient way of packing a large (i.e. > 1MB)
>        list of integers (that are in the range 0 to 255)
>        into a Python string as a sequence of contiguous bytes?

Read the documentation of the array module.
Or just "".join(map(chr, list))...

Moshe Zadka <sig at>
This is a signature anti-virus. 
Please stop the spread of signature viruses!

More information about the Python-list mailing list