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


Groups > comp.lang.python > #35989

Re: why the output is different when i am implementig multiline string

Path csiph.com!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.029
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'converts': 0.07; 'newline': 0.07; 'subject:string': 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'renders': 0.16; 'repr()': 0.16; 'subject:when': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'jan': 0.18; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; '>>>>': 0.29; "skip:' 10": 0.30; 'url:python': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'url:org': 0.36; 'url:library': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'world': 0.63; '1:00': 0.84; '2013': 0.84; 'literally.': 0.84; 'url:functions': 0.84
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 :content-type; bh=LdUVj4uKUFUrfjgZH7G0QmoZHTXN1h+YF9Ymoh2uxps=; b=NIVvNM6mN+NrFJZ3n/wvjO7/dhZr+50S7V1FlVgPX/Rh4yUozOacsNrb70pFSj6MJU zK4XpNUVUUQbxeaUb+CSmqTF05Ak6U2myQ65Hnh62ZrPSJSs0RhJ0Hq3TCz8eDAsmTBf jbvRsBgwqmR4JcXrNx38CmwNSwzXOGV79v3FGIXSm/E8+uE48mB6X29vCc/FYv+t+sBz egmSbbt9KDV0tsW4OsxoY+srWB7qOZdRGqDEmUQKBOFO3FW8n11V9SD6yPzm2B735Hxu d6MkFcRnEXM19bmE5lTavgs2CaZM8FzM9FCSgB+mc1twJIh7lQibo3U34Ln5ejyY10FR +30g==
MIME-Version 1.0
In-Reply-To <e7c60393-8d39-40f8-9e7a-800b39169721@googlegroups.com>
References <e7c60393-8d39-40f8-9e7a-800b39169721@googlegroups.com>
Date Thu, 3 Jan 2013 01:21:51 +1100
Subject Re: why the output is different when i am implementig multiline string
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
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.1568.1357136513.29569.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357136513 news.xs4all.nl 6868 [2001:888:2000:d::a6]:43509
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:35989

Show key headers only | View raw


On Thu, Jan 3, 2013 at 1:00 AM,  <stringsatif1@gmail.com> wrote:
>>>> '''hello
> world'''
> 'hello\nworld'
>>>> fred=''' hello
> world'''
>>>> print(fred)
>  hello
> world

That's because repr() converts the newline into "\n", while print
renders it literally. Check out repr() in the docs:

http://docs.python.org/3/library/functions.html?highlight=repr#repr

ChrisA

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


Thread

why the output is different when i am implementig multiline string stringsatif1@gmail.com - 2013-01-02 06:00 -0800
  Re: why the output is different when i am implementig multiline string Chris Angelico <rosuav@gmail.com> - 2013-01-03 01:21 +1100
  Re: why the output is different when i am implementig multiline string Dave Angel <d@davea.name> - 2013-01-02 09:22 -0500

csiph-web