[Patches] [Patch #103029] Implementation of chomp() on string objects.

noreply@sourceforge.net noreply@sourceforge.net
Mon, 01 Jan 2001 09:47:23 -0800


Patch #103029 has been updated. 

Project: python
Category: core (C code)
Status: Rejected
Submitted by: bjorn_pettersen
Assigned to : nobody
Summary: Implementation of chomp() on string objects.

Follow-Ups:

Date: 2001-Jan-01 09:47
By: gvanrossum

Comment:
I don't typically have the time to follow c.l.py anymore, so I wasn't aware
of that. Would you mind pointing me to the discussion (a Deja.com URL would
be dandy)?

Your suggestion of rmLineTerm() for the method name suggests that you
haven't done Python for very long either. Compare the other string method
names.

There's also the issue of why bother stripping \r and \r\n; if you're
reading using f.readline(), these would already have been converted to \n.
-------------------------------------------------------

Date: 2000-Dec-29 09:08
By: bjorn_pettersen

Comment:
It was almost universally felt (on c.l.py) that a method doing this would
be a good idea (since rstrip does too much, and splitlines() would be
rather cryptic when used in the common "while 1:" idiom -- not to mention
that the common "line = line[:-1]" is completely wrong).

Naming was an issue. I don't do Perl, but even I know what chomp is after a
dozen or so requests on c.l.py. Perhaps rmLineTerm() or some such would be
better?

If this is reconsidered, I'd be glad to implement a patch for both the
unicode string and the documentation.
-------------------------------------------------------

Date: 2000-Dec-28 09:52
By: gvanrossum

Comment:
Rejecting this now.  Comments on python-dev are mostly negative.

Note that there's also splitlines().
-------------------------------------------------------

Date: 2000-Dec-28 07:02
By: gvanrossum

Comment:
Hm. s.rstrip() does the same thing (plus strips trailing whitespace, which
is rarely a problem).  Do you really need this function?  If so, please
don't call it chomp() -- that's a Perl-ism that makes no sense to anyone
else.

*If* (and I say *if*) this is accepted, we would require a Unicode version
and documentation as well.
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=103029&group_id=5470