Function override?
Bernhard Herzog
herzog at online.de
Sat Apr 1 17:25:43 EST 2000
"David C. Ullrich" <ullrich at math.okstate.edu> writes:
> Or I could if I hadn't just read the bit about how in 1.6 strings
> have a split method, and if s1 and s2 are strings then
>
> s1.split(s2)
>
> either splits s1 using s2 as the delimiter or the other way around,
> depending on which occurs more frequently in the other. I mean
> surely it will happen that we want to split a bunch of strings
> using 'delimiter' as a delimiter, and then it just happens that
> the routine that does that gets passed 'lim' as an argument and
> does the opposite of what we want?
Oh, that's easy to work around. I'm sure we'll all get used to the
following new idiom:
(text + delim).split(delim)[:-1]
Surely, this is not harder to learn than:
while 1:
line = file.readline()
if not line:
break
# do something
or
while 1:
# loop body
if some_condition:
break
--
Bernhard Herzog | Sketch, a drawing program for Unix
herzog at online.de | http://sketch.sourceforge.net/
More information about the Python-list
mailing list