Explicitly use floor division

This commit is contained in:
Raymond Hettinger 2002-10-21 04:44:11 +00:00
parent d058f08e03
commit fca3bb6a29
1 changed files with 1 additions and 1 deletions

View File

@ -99,7 +99,7 @@ def replace(text, *pairs):
def cram(text, maxlen): def cram(text, maxlen):
"""Omit part of a string if needed to make it fit in a maximum length.""" """Omit part of a string if needed to make it fit in a maximum length."""
if len(text) > maxlen: if len(text) > maxlen:
pre = max(0, (maxlen-3)/2) pre = max(0, (maxlen-3)//2)
post = max(0, maxlen-3-pre) post = max(0, maxlen-3-pre)
return text[:pre] + '...' + text[len(text)-post:] return text[:pre] + '...' + text[len(text)-post:]
return text return text