Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #27646

Re: help me debug my "word capitalizer" script

Date 2012-08-22 16:40 +0100
From MRAB <python@mrabarnett.plus.com>
Subject Re: help me debug my "word capitalizer" script
References <mailman.3631.1345616511.4697.python-list@python.org> <50349669$0$6846$e4fe514c@news2.news.xs4all.nl>
Newsgroups comp.lang.python
Message-ID <mailman.3658.1345650036.4697.python-list@python.org> (permalink)

Show all headers | View raw


On 22/08/2012 09:20, Hans Mulder wrote:
[snip]
>
> Alternatively, if you want to remove only the line separator,
> you could do:
>
>          if line.endswith(linesep):
>              line = line[:-len(linesep)]
>
> The 'if' command is only necessary for the last line, which may or
> may not end in a linesep.  All earlier lines are guaranteed to end
> with a linesep.
>
Even better is:

     line = line.rstrip(linesep)

The line separator is '\n'.

Strictly speaking, the line separator varies according to platform
(Windows, *nix, etc), but it's translated to '\n' on reading from a
file which has been opened in text mode (the default).

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

help me debug my "word capitalizer" script Santosh Kumar <sntshkmr60@gmail.com> - 2012-08-22 11:51 +0530
  Re: help me debug my "word capitalizer" script Hans Mulder <hansmu@xs4all.nl> - 2012-08-22 10:20 +0200
    Re: help me debug my "word capitalizer" script MRAB <python@mrabarnett.plus.com> - 2012-08-22 16:40 +0100

csiph-web