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


Groups > comp.lang.python > #19604 > unrolled thread

Re: add two strings

Started byDennis Lee Bieber <wlfraed@ix.netcom.com>
First post2012-01-30 10:08 -0500
Last post2012-01-30 10:08 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#19604 — Re: add two strings

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2012-01-30 10:08 -0500
SubjectRe: add two strings
Message-ID<mailman.5216.1327936130.27778.python-list@python.org>
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/

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web