[Tutor] Re: re.match enigma

Lee Harr missive at hotmail.com
Fri Jan 9 14:57:53 EST 2004

for counter in range(0, len(ms2_data[spectrum]['spectrum'])):
        re.match(r"^[\d\.]+", spectrum_data)
        spectrum_data = string.join(
                           ms2_data[spectrum]['spectrum'][counter], '|')
        spectrum_data = string.join(
                                        [spectrum_data, string.join(
                 ms2_data[spectrum]['spectrum'][counter], '|')], '#')

Your function came through pretty garbled.  Above is how I
interpreted it...

A few things:

Try catching only the exception you believe you will throw, instead
of any possible exception ... you never know if you might have some
other error in there (even just a simple syntax error)

It might be clearer if you save the pieces you want to join in to
temporary variables. That way you can print them out as you go
also to see what exactly is happening.

Are you doing this just so you don't have to initialize spectrum_data?
This whole construction seems strange to me ... especially how you
do not save or use the return value from the re.match()

Protect your PC - get McAfee.com VirusScan Online 

More information about the Tutor mailing list