Case consistency [was: Re: [Python-checkins] cpython: Cleanup code: remove int/long idioms and simplify a while statement.]
Is there a reason to check for
if s[:5] == 'pass ' or s[:5] == 'PASS ':
instead of
if s[:5].lower() == 'pass'
?
If so, it should be documented; otherwise, I would rather see the more
inclusive form, that would also allow things like "Pass"
-jJ
On Sun, Oct 23, 2011 at 4:21 PM, florent.xicluna
http://hg.python.org/cpython/rev/67053b135ed9 changeset: 73076:67053b135ed9 user: Florent Xicluna
date: Sun Oct 23 22:11:00 2011 +0200 summary: Cleanup code: remove int/long idioms and simplify a while statement.
diff --git a/Lib/ftplib.py b/Lib/ftplib.py --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -175,10 +175,8 @@
# Internal: "sanitize" a string for printing def sanitize(self, s): - if s[:5] == 'pass ' or s[:5] == 'PASS ': - i = len(s) - while i > 5 and s[i-1] in {'\r', '\n'}: - i = i-1 + if s[:5] in {'pass ', 'PASS '}: + i = len(s.rstrip('\r\n')) s = s[:5] + '*'*(i-5) + s[i:] return repr(s)
participants (1)
-
Jim Jewett