Hi Oliver,
vielleicht hat schon jemand von euch dieses Problem gehabt und kann mir einen Tip oder Lösung geben.
Nö, aber ich hab's grad mal geschrieben. Nicht ganz komplett, denn er meckert nicht bei parser('["abc",,,]') aber er merkt inkorrekte Klammerung. ciao - chris -- Christian Tismer :^) <mailto:tismer@stackless.com> Mission Impossible 5oftware : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/ s='[["abc","abc",["abc","abc"],"abc"],["abc","abc",["abc","abc"],["abc",["abc","abc"]],"abc"],"abc"]' class ParserError(Exception): pass def parser(txt): lis = st = [] q = False ob = None def put(ob): if ob is not None: lis.append(ob) for c in txt: if not q: if c == '[': st.append(lis) lis = [] elif c == ']': if lis is st: raise ParserError, 'unmatched "]"' put(ob) ob = lis lis = st.pop() elif c == ',': put(ob) ob = None elif c == '"': q = True ob = '' elif not c.isspace(): raise ParserError, 'unexpected "%c"' %c else: if c == '"': q = False else: ob += c if st: raise ParserError, 'unmatched "["' return ob assert parser(s) == eval(s) _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de