gah! I hate the new string syntax

Fredrik Lundh fredrik at pythonware.com
Fri Mar 2 08:40:17 CET 2001


Sean 'Shaleh' Perry wrote:
> return ";".join(["%s=%s" % (k, params[k]) for k in params.keys()])
>
> every day python seems to be moving closer to the line noise aspect of
> coding.

you're using list comprehensions and the wrong dictionary method,
and then you're complaining about string methods? ;-)

("items()" returns a key/value tuple that you can pass directly to
the formatting operator.  and nobody will complain if you stick to
string.join for stuff like this...)

Cheers /F





More information about the Python-list mailing list