I have a parsing system for fixed-length text records based on a layout table:
parse_table = [\\ (\'name\', type, length), .... (\'numeric_field\
Use a factory function instead of int or a subclass of int:
def mk_int(s): s = s.strip() return int(s) if s else 0