Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'trailing': 0.07; 'ignoring': 0.09; 'cc:addr:python-list': 0.10; 'dec': 0.15; '6:00': 0.16; 'received:74.125.82.46': 0.16; 'subject:Problem': 0.16; 'subject:screen': 0.16; 'wrote:': 0.17; 'strip': 0.22; '>': 0.23; '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; 'cc:addr:gmail.com': 0.27; 'forgot': 0.27; 'message- id:@mail.gmail.com': 0.27; 'equivalent.': 0.29; 'case,': 0.29; 'character': 0.29; 'included': 0.29; 'point': 0.31; 'file': 0.32; 'received:74.125.82': 0.33; '11,': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'pm,': 0.35; 'but': 0.36; 'received:74.125': 0.36; 'method': 0.36; 'subject:with': 0.36; 'subject:: ': 0.38; 'files': 0.38; 'instead': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'your': 0.60; 'most': 0.61; 'taken.': 0.84; 'joel': 0.91; 'angel': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=qQgKhYl8VkUbifQDikjWTd7MHdYLcsLP/hEbPC0THTA=; b=irGdOp1Nln8BwSnn3K3X6dGQW1RbfC64zGGxvxH14/zyyYgP4gFrqQeUE2C0uhoNHr e6vu/urVUjmzB3TsCg7zX894GLHCVbLglL9xKyMT32lPc+Ra31BCk8dqI4XsudA69nLX qDFTl8ERomQcysPohQPjNVlYWJe9wCxpjgSW9nkIhRZ3qKgnOes24uF2YXcAIwS3eCqK +6faVuYPvezAzQD32YG5eisUmd/uolat7Q2O/nGDWO3yw5VfSFNy61RK3BXEa9RJbbap 4JCmPs8NkCqL542psVTJC5+4v7xgi/9rUt5ri3EiJCR0+VJvIt+Hk7OLxrkk2TbwzH8S d1iw== MIME-Version: 1.0 In-Reply-To: <50C7BB20.2020701@davea.name> References: <37e2ba70-a709-4888-9672-be30956d690d@googlegroups.com> <50C7BB20.2020701@davea.name> Date: Tue, 11 Dec 2012 18:07:09 -0500 Subject: Re: Problem with print and output to screen From: Joel Goldstick To: d@davea.name Content-Type: multipart/alternative; boundary=089e0118450ad3006204d09bbd1d Cc: "python-list@python.org" , Mike X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 69 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355267237 news.xs4all.nl 6978 [2001:888:2000:d::a6]:43446 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34663 --089e0118450ad3006204d09bbd1d Content-Type: text/plain; charset=UTF-8 On Tue, Dec 11, 2012 at 6:00 PM, Dave Angel wrote: > 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. > > Point taken. Brain freeze. I forgot about .rstrip. That is the way to go > > -- > > DaveA > > -- Joel Goldstick --089e0118450ad3006204d09bbd1d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Tue, D= ec 11, 2012 at 6:00 PM, Dave Angel <d@davea.name> wrote:
On 12/11/2012 05:53 PM, Joel Goldstick wrote:
> When you read the file line by line the end of line character is inclu= ded
> 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. =C2=A0In that case, we'd be ignoring the last character of the= line.

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

Point taken.=C2=A0 Brain freeze.=C2=A0 I forgot about .rstrip.=C2=A0 That i= s the way to go

--

DaveA




--
Joel Gold= stick

--089e0118450ad3006204d09bbd1d--