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


Groups > comp.lang.python > #34662

Re: Problem with print and output to screen

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!feed.xsnews.nl!border-2.ams.xsnews.nl!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.071
X-Spam-Evidence '*H*': 0.86; '*S*': 0.00; 'trailing': 0.07; 'ignoring': 0.09; 'cc:addr:python-list': 0.10; 'subject:Problem': 0.16; 'subject:screen': 0.16; 'wrote:': 0.17; 'strip': 0.22; 'purposes': 0.23; "we'd": 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'cc:addr:gmail.com': 0.27; 'equivalent.': 0.29; 'case,': 0.29; 'character': 0.29; 'included': 0.29; 'file': 0.32; 'text': 0.34; 'pm,': 0.35; 'but': 0.36; 'method': 0.36; 'subject:with': 0.36; 'subject:: ': 0.38; 'files': 0.38; 'instead': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'end': 0.40; 'your': 0.60; 'most': 0.61; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84; 'joel': 0.91
Date Tue, 11 Dec 2012 18:00:48 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1
MIME-Version 1.0
To Joel Goldstick <joel.goldstick@gmail.com>
Subject Re: Problem with print and output to screen
References <37e2ba70-a709-4888-9672-be30956d690d@googlegroups.com> <CAPM-O+yJr17oCES1EVysx2Ht4VS3Z940T86xc_mZ_H0AN2eZ7A@mail.gmail.com>
In-Reply-To <CAPM-O+yJr17oCES1EVysx2Ht4VS3Z940T86xc_mZ_H0AN2eZ7A@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:EZWM1pyk3mzzMEk2338EZNHOPin7Wq2nXy+x0kwxuLo kdS7vKqcZbUhaHyAn/sFhbUwHzIyxo4mVMU2hVtGiVmrlg3cJS cbmiGyeBMlwVpi9blFpw76unniDyVWihempn7cDLVZwzs8zKdw dbGni2oiq47DENezzIWNldnboElOIU78mj9DLpt8/1gpX3ZoY6 GID69PYpwg5a6MNK2J36m5V1F4ioFbrdWPnvkihHt0VPIT/YJ9 e7lgOdw+uA+PK+f693X1npmFghfLYvHhxjcMIaxZANJT5J2vEK V4MEwz5Koqa8KlX95RVLLErQg4gt751ldkTtgkwsJPSYy3s8A= =
Cc "python-list@python.org" <python-list@python.org>, Mike <miguelcoam@gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To d@davea.name
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.755.1355266880.29569.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1355266880 news.xs4all.nl 6893 [2001:888:2000:d::a6]:40648
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34662

Show key headers only | View raw


On 12/11/2012 05:53 PM, Joel Goldstick wrote:
> When you read the file line by line the end of line character is included
> in the result
>
> try user[:-1] instead to strip the return from your printed text
>

The catch to that is the last line in the file might not have a
newline.  In that case, we'd be ignoring the last character of the line.

The .rstrip() method is easy, and for most purposes equivalent.  Few
text files have trailing whitespace, but many are missing the final
linefeed.



-- 

DaveA

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


Thread

Problem with print and output to screen Mike <miguelcoam@gmail.com> - 2012-12-11 14:31 -0800
  Re: Problem with print and output to screen Dave Angel <d@davea.name> - 2012-12-11 17:48 -0500
  Re: Problem with print and output to screen Joel Goldstick <joel.goldstick@gmail.com> - 2012-12-11 17:53 -0500
  Re: Problem with print and output to screen Dave Angel <d@davea.name> - 2012-12-11 18:00 -0500
  Re: Problem with print and output to screen Joel Goldstick <joel.goldstick@gmail.com> - 2012-12-11 18:07 -0500
    Re: Problem with print and output to screen Mike <miguelcoam@gmail.com> - 2012-12-11 16:44 -0800
    Re: Problem with print and output to screen Mike <miguelcoam@gmail.com> - 2012-12-11 16:44 -0800

csiph-web