Re: Parsing Strings in Enclosed in Curly Braces

2009-05-16 Thread John Machin
On May 17, 1:28 am, a...@pythoncraft.com (Aahz) wrote: > In article > <180531ca-33aa-47b9-9c69-5b5973f6b...@v35g2000pro.googlegroups.com>, > John Machin   wrote: > >Neat trick. However, from 2.6.2: > > help(sum) > >Help on built-in function sum in module __builtin__: > > >sum(...) > >    sum(

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-16 Thread Kay Schluehr
> Since when is a list a number? Perhaps the help needs clarification, > in line with the docs. Everyone is supposed to use reduce() here ;) Kay -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-16 Thread Aahz
In article <180531ca-33aa-47b9-9c69-5b5973f6b...@v35g2000pro.googlegroups.com>, John Machin wrote: > >Neat trick. However, from 2.6.2: > help(sum) >Help on built-in function sum in module __builtin__: > >sum(...) >sum(sequence[, start]) -> value > >Returns the sum of a sequence of nu

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread Rhodri James
On Fri, 15 May 2009 17:12:24 +0100, wrote: How do you parse a string enclosed in Curly Braces? For instance: x = "{ABC EFG IJK LMN OPQ}" I want to do x.split('{} ') and it does not work. Why does it not work and what are EXCEPTIONS to using the split method? Other people have already done

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread John Machin
On May 16, 3:25 am, MRAB wrote: > Chris Rebert wrote: > > On Fri, May 15, 2009 at 9:12 AM,   wrote: > >> How do you parse a string enclosed in Curly Braces? > > >> For instance: > > >> x = "{ABC EFG IJK LMN OPQ}" > > >> I want to do x.split('{} ') and it does not work. Why does it not work > >> an

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread Peter Otten
k...@fiber-space.de wrote: > ttable = string.maketrans("{} ", "\1\1\1") > print x.translate(ttable).split("\1") # -> ['', 'ABC', 'EFG', 'IJK', > 'LMN', 'OPQ', ''] > > The validity of the translation+split depends on the presence of \1 in > the original string of course. Keep one of the split

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread kay
On 15 Mai, 18:12, xama...@yahoo.com wrote: > How do you parse a string enclosed in Curly Braces? > > For instance: > > x = "{ABC EFG IJK LMN OPQ}" > > I want to do x.split('{} ') and it does not work. Why does it not work > and what are EXCEPTIONS to using the split method? > > That I want to split

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread MRAB
Chris Rebert wrote: On Fri, May 15, 2009 at 9:12 AM, wrote: How do you parse a string enclosed in Curly Braces? For instance: x = "{ABC EFG IJK LMN OPQ}" I want to do x.split('{} ') and it does not work. Why does it not work and what are EXCEPTIONS to using the split method? .split() take

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread Mike Driscoll
On May 15, 11:12 am, xama...@yahoo.com wrote: > How do you parse a string enclosed in Curly Braces? > > For instance: > > x = "{ABC EFG IJK LMN OPQ}" > > I want to do x.split('{} ') and it does not work. Why does it not work > and what are EXCEPTIONS to using the split method? > > That I want to sp

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread Chris Rebert
On Fri, May 15, 2009 at 9:12 AM, wrote: > How do you parse a string enclosed in Curly Braces? > > For instance: > > x = "{ABC EFG IJK LMN OPQ}" > > I want to do x.split('{} ') and it does not work. Why does it not work > and what are EXCEPTIONS to using the split method? .split() takes a *substr