[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Making string-formatting smarter by handling generators?

Boris Borcic

2/27/2008 7:26:00 PM

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