Added a return value to shrinkList, the number of things removed from the list.

This commit is contained in:
Jeremy Fincher 2003-08-23 09:07:45 +00:00
parent 320f1d26b7
commit f0b533098c

View File

@ -293,8 +293,11 @@ def privmsgPayload(L, sep, limit=425):
def shrinkList(L, sep='', limit=425): def shrinkList(L, sep='', limit=425):
"""Shrinks a list of strings to a given combined length of limit.""" """Shrinks a list of strings to a given combined length of limit."""
length = len(sep) length = len(sep)
count = 0
while reduce(operator.add, map(length.__add__, map(len, L)), 0)> limit: while reduce(operator.add, map(length.__add__, map(len, L)), 0)> limit:
L.pop() L.pop()
count += 1
return count
class IrcString(str): class IrcString(str):