[Python-Dev] Case consistency [was: Re: [Python-checkins] cpython: Cleanup code: remove int/long idioms and simplify a while statement.] (original) (raw)
Jim Jewett jimjjewett at gmail.com
Mon Oct 24 19:04:20 CEST 2011
- Previous message: [Python-Dev] Deprecation policy
- Next message: [Python-Dev] Use our strict mbcs codec instead of the Windows ANSI API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <python-checkins at python.org> wrote:
http://hg.python.org/cpython/rev/67053b135ed9 changeset: 73076:67053b135ed9 user: Florent Xicluna <florent.xicluna at gmail.com> 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)
- Previous message: [Python-Dev] Deprecation policy
- Next message: [Python-Dev] Use our strict mbcs codec instead of the Windows ANSI API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]