Paul, thanks for the enlightening intro to pyparsing! We don't really know what the application is (I suspect it's homework), but whether it's homework or a real-world one-off this all seems like overkill to me. There's a time for elegance and a time for quick and dirty. Assuming line oriented input as shown, I can do it in 9 simple lines (or 7, if there is no "level3" or higher case) with no imports, no regular expressions, and no user defined classes. However, I hate to submit someone's homework.
Anyway, Provo seems confused, and should focus more on technique, I think. Remember that "simple is better than complex" and "readability counts". Try to find a way to take smaller steps toward your goal. mt -- http://mail.python.org/mailman/listinfo/python-list