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

Question on Strings

2009-02-06 Thread Kalyankumar Ramaseshan
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? b) They are converted to utf-8 format when it is needed for e.g. when storing the string to disk o

Re: newb question on strings

2008-06-27 Thread Kirk Strauser
At 2008-06-24T20:27:33Z, regex_jedi <[EMAIL PROTECTED]> writes: > Notice that the 4th value has a single quote in it. Well, I need to > make sure that the single quote is escaped before handing it off for > further processing to a class I later call for some other processing. Out of curiosity, wh

Re: newb question on strings

2008-06-25 Thread Cédric Lucantis
Le Tuesday 24 June 2008 22:27:33 regex_jedi, vous avez écrit : > ok, I have looked a lot of places, and can't seem to get a clear > answer... > > I have a string called >each_theme > > Some values of the string may contain a single quote as in - >Happy >Sad >Nice >Frank's Laundr

Re: newb question on strings

2008-06-25 Thread Bruno Desthuilliers
Dan Bishop a écrit : On Jun 24, 4:04 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: Are you trying to escape for a regular expression? Just do re.escape(). print re.escape('Happy') Happy print re.escape("Frank's Diner") Frank\'s\ Diner If you're escaping for URLs, there's urllib2.quot

Re: newb question on strings

2008-06-24 Thread Dan Bishop
On Jun 24, 4:04 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Are you trying to escape for a regular expression? > > Just do re.escape(). > > >>> print re.escape('Happy') > Happy > >>> print re.escape("Frank's Diner") > > Frank\'s\ Diner > > If you're escaping for URLs, there's urllib2.quote

Re: newb question on strings

2008-06-24 Thread [EMAIL PROTECTED]
Are you trying to escape for a regular expression? Just do re.escape(). >>> print re.escape('Happy') Happy >>> print re.escape("Frank's Diner") Frank\'s\ Diner If you're escaping for URLs, there's urllib2.quote(), for a command line, use subprocess.list2cmdline. Generally, the module that consu

newb question on strings

2008-06-24 Thread regex_jedi
ok, I have looked a lot of places, and can't seem to get a clear answer... I have a string called each_theme Some values of the string may contain a single quote as in - Happy Sad Nice Frank's Laundry Explosion Notice that the 4th value has a single quote in it. Well, I need to