On Thu, 11 Dec 2008 23:49:10 -0000, John Machin <sjmac...@lexicon.net> wrote:

On Dec 12, 10:31 am, "Rhodri James" <rho...@wildebst.demon.co.uk>
wrote:
On Thu, 11 Dec 2008 19:49:23 -0000, Steve Holden <st...@holdenweb.com>  
wrote:
> ... and it's so hard to write

>      item = item[:-1]

Tsk.  That would be "chop".  "chomp" would be

     if item[-1] == '\n':
         item = item[:-1]

Better:
if item and item[-1] == '\n':
    return item[:-1]
return item

If we aren't going for rstrip, yes, but I was trying to stick to Steve's metier.

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to