gah! I hate the new string syntax
Carl Banks
idot at vt.edu
Fri Mar 2 11:41:14 EST 2001
Robin Becker <robin at jessikat.fsnet.co.uk> wrote:
> In article <0vpn79.331.ln at 127.0.0.1>, Carl Banks <idot at vt.edu> writes
>>Sean 'Shaleh' Perry <shaleh at valinux.com> 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.
>>
>>I find it ok for methodlike functions such as split.
>>
>>For unmethodlike functions such as join, I would use the old
>>string.join syntax (for regular strings, anyways).
>>
>>"".join is just creepy.
>>
> it looks plain wrong, but would ['a','b','c'].join(';') look any better?
No, but string.join(['a','b','c'],';') does look better, IMO.
> In fact there may be some benefit in being able to say
> pathJoiner = (sys.platform=='win32' and ';' or ':').join
> .....
> path1 = pathJoiner([d1,d2,.....])
> path2 = pathJoiner([e1,e2,.....])
Sure. I'm not saying join should not be a method, only that I prefer
the function invocation as a matter of style. Most other string
methods are ok, but this one I find supremely weird.
--
CARL BANKS
"I like nothing better than a good challenge.
This is not one of them."
More information about the Python-list
mailing list