Peter Hansen schrieb:
> Matt's answer is still the only one that passes the tests.

well, here's another one:

-----------------------------
def mysplit(s, sep):
    x = s.rsplit(sep, 1)
    return x + ['']*(2-len(x))

def stripZeros(x):
    intpart, frac = mysplit(x, '.')
    frac = frac.rstrip('0')
    if frac:
        return intpart+'.'+frac
    else:
        return intpart
-----------------------------

i only mention this one, because i just remembered the discussion
about a str.partition method, which could save this version the
extra function. what happened to that method?

for anyone interested, it was proposed here:

  http://mail.python.org/pipermail/python-dev/2005-August/055764.html

--
David.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to