Making string-formatting smarter by handling generators?
Boris Borcic
bborcic at gmail.com
Wed Feb 27 14:25:55 EST 2008
D'Arcy J.M. Cain wrote:
>> I find I hit it mostly with calls to map() where I want to apply
>> some transform (as above) to all the items in a list of
>> parameters such as
>>
>> "%s=%s&%s=%s" % map(urllib.quote, params)
>
> Isn't map() deprecated? The above can be done with;
>
> "%s=%s&%s=%s" % tuple([urllib.quote(x) for x in params])
>
>> Any suggestions? (even if it's just "get over your hangup with
>> wrapping the results in list()/tuple()" :)
>
> Pretty much. :-)
>
...except for saving on a level of brackets or parens, since you can actually write
"%s=%s&%s=%s" % tuple(urllib.quote(x) for x in params)
instead of the above
More information about the Python-list
mailing list