Re: Question on Strings

2009-02-06 Thread John Machin
On Feb 7, 5:23 am, Terry Reedy wrote: > John Machin wrote: > > The UTF-n siblings are *external* representations. > > 2.x: a_unicode_object.decode('UTF-16') -> an_str_object > > 3.x: an_str_object.decode('UTF-16') -> a_bytes_object > > That should be .encode() to bytes, which is the coded form. >

Re: Question on Strings

2009-02-06 Thread Terry Reedy
John Machin wrote: The UTF-n siblings are *external* representations. 2.x: a_unicode_object.decode('UTF-16') -> an_str_object 3.x: an_str_object.decode('UTF-16') -> a_bytes_object That should be .encode() to bytes, which is the coded form. .decode is bytes => str/unicode -- http://mail.python

Re: Question on Strings

2009-02-06 Thread Hendrik van Rooyen
"John Machin" wrote: >By the way, has anyone come up with a name for the shifting effect >observed above on str, and also with repr, range, and the iter* >family? If not, I suggest that the language's association with the >best of English humour be widened so that it be dubbed the "Mad >Hatter's

Re: Question on Strings

2009-02-06 Thread MRAB
John Machin wrote: > On Feb 6, 9:24 pm, Chris Rebert wrote: >> On Fri, Feb 6, 2009 at 1:49 AM, Kalyankumar Ramaseshan >> >> wrote: >> >>> Hi, >>> Excuse me if this is a repeat question! >>> I just wanted to know how are strings represented in python? >>> I need to know in terms of: >>> a) String

Re: Question on Strings

2009-02-06 Thread John Machin
On Feb 6, 9:24 pm, Chris Rebert wrote: > On Fri, Feb 6, 2009 at 1:49 AM, Kalyankumar Ramaseshan > > wrote: > > > Hi, > > > Excuse me if this is a repeat question! > > > I just wanted to know how are strings represented in python? > > > I need to know in terms of: > > > a) Strings are stored as UT

Re: Question on Strings

2009-02-06 Thread Tino Wildenhain
Hi, Kalyankumar Ramaseshan wrote: Hi, Excuse me if this is a repeat question! I just wanted to know how are strings represented in python? It depents on if you mean python2.x or python3.x - the model changed. Python 2.x knows str and unicode - the former a sequence of single byte character

Re: Question on Strings

2009-02-06 Thread Chris Rebert
On Fri, Feb 6, 2009 at 1:49 AM, Kalyankumar Ramaseshan wrote: > > Hi, > > Excuse me if this is a repeat question! > > I just wanted to know how are strings represented in python? > > I need to know in terms of: > > a) Strings are stored as UTF-16 (LE/BE) or UTF-32 characters? IIRC, Depends on wha