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


Groups > comp.lang.python > #19604

Re: add two strings

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!feeder3.eweka.nl!hq-usenetpeers.eweka.nl!81.171.88.15.MISMATCH!eweka.nl!feeder.eweka.nl!62.179.104.142.MISMATCH!amsnews11.chello.com!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:two': 0.04; 'value,': 0.04; 'interpreter': 0.05; 'ascii': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'displayed': 0.10; 'am,': 0.12; 'win32': 0.12; 'mon,': 0.15; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '"print"': 0.16; '%r"': 0.16; '>it': 0.16; '>on': 0.16; 'bieber': 0.16; 'email addr:ix.netcom.com': 0.16; 'email name:wlfraed': 0.16; 'from:addr:ix.netcom.com': 0.16; 'from:addr:wlfraed': 0.16; 'from:name:dennis lee bieber': 0.16; 'hex': 0.16; 'inverse': 0.16; 'message-id:@4ax.com': 0.16; 'pythonwin': 0.16; 'received:wlfraed': 0.16; 'string:': 0.16; 'url:netcom': 0.16; 'url:wlfraed': 0.16; 'wulfraed': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'jan': 0.19; 'url:home': 0.21; 'feb': 0.22; 'documented': 0.23; 'literal': 0.23; 'produces': 0.23; 'received:166': 0.23; 'string': 0.24; 'command': 0.24; 'windows': 0.26; 'code.': 0.26; 'lee': 0.28; 'producing': 0.28; 'bit': 0.28; 'print': 0.29; 'second': 0.29; '(and': 0.29; 'invoke': 0.30; "didn't": 0.30; 'source': 0.32; 'to:addr:python-list': 0.33; 'showing': 0.34; 'header:X-Complaints-To:1': 0.34; 'charset:us-ascii': 0.36; 'received:org': 0.37; 'using': 0.37; 'why': 0.39; 'plain': 0.39; 'subject:: ': 0.39; 'did': 0.39; 'to:addr:python.org': 0.40; 'video': 0.60; 'type': 0.60; 'more': 0.61; 'agent': 0.65; 'subject:add': 0.67; 'dennis': 0.73; '-0500,': 0.84; '2.7.1': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: add two strings
Date Mon, 30 Jan 2012 10:08:31 -0500
References <CA+YdQ_6cp=9dQ65P3TTNTJLG54stCiX9x1RNSV=4akVQQKUTFw@mail.gmail.com> <4F2699CA.8070305@davea.name>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host mobile-166-147-102-044.mycingular.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.5216.1327936130.27778.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1327936130 news.xs4all.nl 6926 [2001:888:2000:d::a6]:55895
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19604

Show key headers only | View raw


On Mon, 30 Jan 2012 08:23:22 -0500, Dave Angel <d@davea.name> wrote:

>On 01/30/2012 08:02 AM, contro opinion wrote:
>>>>> s1='\x45'
>>>>> s2='\xe4'
>>>>> s1+s2
>> 'E\xe4'
>>>>> print  s1+s2
>> E
>>
>> why  s1+s2  not  =  '\x45\xe4'??
>>
>It is.  "E" is  "\x45".  That's plain ASCII and documented everywhere.

	The second factor is that "print" produces a "user-world" rendition,
whereas the interpreter without using print is producing a
representation suitable as a string literal within Python source code.

(Hmmm, PythonWin displayed inverse video hex value, which didn't
cut&paste to Agent well)

>>> s1 = "\x45"
>>> s2 = "\xe4"
>>> cat = s1 + s2
>>> print "string: %s\tliteral: %r" % (cat, cat)
string: E?iteral: 'E\xe4'
>>>

(and using Windows command line to invoke an interactive session
resulted in showing a cap-Sigma -- which also did not cut&paste well)

C:\Users\Wulfraed>python
ActivePython 2.7.1.4 (ActiveState Software Inc.) based on
Python 2.7.1 (r271:86832, Feb  7 2011, 11:30:38) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> s1 = "\x45"
>>> s2 = "\xe4"
>>> cat = s1 + s2
>>> print "string: %s\tliteral: %r" % (cat, cat)
string: ES      literal: 'E\xe4'
>>>
 
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Thread

Re: add two strings Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-01-30 10:08 -0500

csiph-web