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


Groups > comp.lang.python > #35990

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

Path csiph.com!aioe.org!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.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.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'value,': 0.03; 'string.': 0.04; 'escape': 0.07; 'python': 0.09; 'debugger': 0.09; 'subject:string': 0.09; '(assuming': 0.16; 'debugger.': 0.16; 'expression.': 0.16; 'repr()': 0.16; 'skip:> 20': 0.16; 'subject:when': 0.16; 'wrote:': 0.17; 'sends': 0.22; 'mention': 0.23; "python's": 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'embedded': 0.27; '>>>>': 0.29; 'case,': 0.29; "skip:' 10": 0.30; 'function': 0.30; 'stuff': 0.30; 'print': 0.32; 'quotes': 0.33; 'turns': 0.33; 'to:addr:python-list': 0.33; 'adds': 0.35; 'but': 0.36; 'characters': 0.36; "didn't": 0.36; 'should': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'nothing': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'world': 0.63; 'email addr:gmail.com': 0.63; 'said:': 0.65; 'header:Reply-To:1': 0.68; 'direct': 0.69; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'funny': 0.78
Date Wed, 02 Jan 2013 09:22:16 -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 python-list@python.org
Subject Re: why the output is different when i am implementig multiline string
References <e7c60393-8d39-40f8-9e7a-800b39169721@googlegroups.com>
In-Reply-To <e7c60393-8d39-40f8-9e7a-800b39169721@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:X/QAV1ArwhHPPgWp1izlYYfW0p+JaAECZQsRxp5BhJn G57cFFSYUc25bXlt5H19fGrqksgjd21lVtGTR5uCpQ6yktvCh2 EOCTkOy63cHmZvwtylPdIfvYNlq+IXXT02xg/j2Bh5q4VucUoh tNgpXTbOjcXCntchCYajIMQj7401vFnxn3YEXTTnHnvxhQZ2dY s5wODAMLEHUf/Lak/n4itGERpShA0FHMyGC9xwHQ8yUWci9k7p oiTw1L9B6p2QnQr2kRb0Esk02pfPND8Gv+gKQxV6CaWzcN1L/i qrbmdxQYPa2F8IIBkidEpJud/S077Q3FeI9+8cXGfuVv4Rbdw= =
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.1569.1357136556.29569.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357136556 news.xs4all.nl 6885 [2001:888:2000:d::a6]:44421
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:35990

Show key headers only | View raw


On 01/02/2013 09:00 AM, stringsatif1@gmail.com wrote:
>>>> '''hello
> world'''
> 'hello\nworld'
>>>> fred=''' hello
> world'''
>>>> print(fred)
>  hello
> world

What you're seeing has nothing to do with the triple quotes, and
everything to do with how you're using the debugger.  In one case, you
just mention a value, and the debugger magically calls repr() on the
expression.  So it adds quotes around it, and turns embedded funny stuff
into escape sequences, because that's what repr() does on a string.

In the second case, you call Python's print function (assuming python 3,
which you didn't specify).  it does not call repr(), but just sends the
characters direct to the console.

if you want to see the escape characters in the second case, you should
have either said:

>>>fred

or

>>>print(repr(fred))



-- 

DaveA

Back to comp.lang.python | Previous | NextPrevious 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