problem with split

Steve Holden steve at holdenweb.com
Sat Oct 7 05:48:04 EDT 2006


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
> 

.group() is a *method of the patch object not a data attribute, so you 
have to *call* it, not treat it like a list or dict. Try something like

return (s.group(1), s.group(2))

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list