[docs] Typo in example code in section 6.2.6.10 in python3.3 documentation

Vikram Shirgur vikramls at gmail.com
Mon May 2 19:52:52 CEST 2011


Hi,

There seems to be a typo in the listing for section 6.2.6.10. The
relevant code says this:

#-- begin code snippet
        elif typ != 'SKIP':
            if typ == 'ID' and val in keywords:
                typ = val
            yield Token(typ, mo.group(typ), line, mo.start()-line_start)
#-- end code snippet

which results in NameError since val hasn't been defined before. It
should be changed to:

#-- begin code snippet
        elif typ != 'SKIP':
            val = mo.group(typ)
            if typ == 'ID' and val in keywords:
                typ = val
            yield Token(typ, val, line, mo.start()-line_start)
#-- end code snippet

I added a statement (val = mo.group(typ)) to assign a value to val
before it is accessed.

Thanks,
Vikram


More information about the docs mailing list