Re:What is the most intrusive wart on your favourite program...
by rbanffy on Monday December 08, 2008 @06:08AM
(#389731)
I would think a more natural approach of making join a method of any sequence would result in cleaner programs.
(a, b, c).join(',')
instead of: ','.join((a, b, c))
Re:What is the most intrusive wart on your favourite program...
by cabalamat on Monday December 08, 2008 @07:46AM
(#389789)
I agree. Join should word the same as split:
>>> "abcbe".split("b")
['a', 'c', 'e']
So to get back the original string you should be able to say: ['a', 'c', 'e'].join("b") #!!! WRONG !!!
but this doesn't work and instead you have to say: >>> "b".join(['a', 'c', 'e'])
'abcbe'
Re:What is the most intrusive wart on your favourite program...
by zepolen on Monday December 08, 2008 @08:15AM
(#389797)
You miss out on a nice side-effect of join being a method of string:
br = '<br>'.join
br((a, b, c))
Personally I think it makes more sense the ruby way but it's never bugged me.
Re:What is the most intrusive wart on your favourite program...
by rbanffy on Monday December 08, 2008 @11:21AM
(#389970)
Wow... This one is quite pretty. Really. A very nice side effect of the "everything is an object" concept.
Re:What is the most intrusive wart on your favourite program...
by silentbicycle on Monday December 08, 2008 @08:06PM
(#390720)
There's not any reason you need objects for that, though. Python's join in the string module is called as join(list [,sep])*, and you could say
def br(sl):
return string.join(sl, "<br>")
or br = lambda sl: string.join(sl, "<br>")
for the same effect. It's actually due to first-class functions.
Re:What is the most intrusive wart on your favourite program...
by apu on Monday December 08, 2008 @12:14AM
(#389516)
What don't you like about this?
Re:What is the most intrusive wart on your favourite program...
by twism on Monday December 08, 2008 @11:19AM
(#389968)
The fact 'join' being a method of a string that accepts an array as an argument. I guess it isn't that bad, I just think I've been conditioned to expect it the other way around.
Re:What is the most intrusive wart on your favourite program...
by Erwin on Monday December 08, 2008 @06:23AM
(#389742)
My string/sequence related annoyince is ''.split() -vs- ''.split(';').
The first returns [], but the second returns [''].
Maybe it shouldn't but this pisses me off.