using generators with format strings

marduk marduk at python.net
Wed Jul 21 22:57:21 CEST 2004


On Wed, 21 Jul 2004 16:38:55 -0400, brianc wrote:

> List comprehension is a beautiful thing.
> 
> x = "Hello, %s, this is a %s with %s and %s on top of %s" %
> tuple([myvalues() for i in xrange(5)])
> 
> You could even make the xrange argument dependent upon the
> number of "%s" in the string. 

Well, that has two problems:

a) the tuple is a list of generators of strings, not strings
b) I was hoping I would not have to count all the "%s"s in the string




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---



More information about the Python-list mailing list