# problem with split

Eric_Dexter at msn.com Eric_Dexter at msn.com
Sat Oct 7 08:56:32 CEST 2006

I am not sure if I am having trouble with the test program or the
routine..  (I had the brackets in the wrong place on the other)

IDLE 1.1.3      ==== No Subprocess ====
>>>
>>>

I get this but I have at least three lines and the

v = []
v = csoundroutines.csdInstrumentList('bay-at-night.csd')
print v

Eric_Dexter at msn.com wrote:
> I think I am very close the return line is tripping me up.  (this is
> the first list that I have tried to program in python)
>
> return (s.group[1], s.group[2])
>
> Traceback (most recent call last):
>   File "C:\Python24\Lib\site-packages\boa-constructor\test of
> snake\test_of_csoundroutines_list.py", line 5, in ?
>     v = csoundroutines.csdInstrumentList('bay-at-night.csd')
>   File "C:\Python24\Lib\site-packages\boa-constructor\test of
> snake\csoundroutines.py", line 43, in csdInstrumentList
>     return (s.group[1], s.group[2])
> TypeError: unsubscriptable object
>
>
>
>
>
>
>
>
>
>
> hanumizzle wrote:
> > On 6 Oct 2006 23:09:08 -0700, MonkeeSage <MonkeeSage at gmail.com> wrote:
> > >
> > >
> > > On Oct 6, 11:33 pm, hanumizzle <hanumiz... at gmail.com> wrote:
> > > > import re
> > > >
> > > > <snip>
> > > >
> > > > if line.startswith('instr'):
> > > >   p = re.compile(r'(\d+)\s+;(.*)\$')
> > > >   m = p.search(line)
> > > >
> > > > return (m.group(1), m.group(2))
> > >
> > > You probably don't want startswith, in case there are initial spaces in
> > > the line.
> >
> > Pardon me; I am not very familiar with file format in question.
> >
> > > Also, since the regexp is single use, you can just use the
> > > re.search class method, which will compile the regexp implicitly.
> >
> > Cool.
> >
> > > May
> > > also want to strip the second grouped match, in case of trailing
> > > spaces.
> >
> > Cosmetic, but good idea.
> >
> > -- Theerasak