How to make "int" parse blank strings?
<p>I have a parsing system for fixed-length text records based on a layout table:</p>

<pre><code>parse_table = [\
    ('name', type, length),
    ....
    ('numeric_field', int, 10), # int example
    ('textc_field', str, 100), # string example
    ...
]
</code></pre>

<p>The idea is that given a table for a message type, I just go through the string, and reconstruct a dictionary out of it, according to entries in the table.</p>

<p>Now, I can handle strings and proper integers, but <code>int()</code> will not parse all-spaces fields (for a good reason, of course).</p>

<p>I wanted to handle it by defining a subclass of <code>int</code> that handles blank strings. This way I could go and change the type of appropriate table entries without introducing additional kludges in the parsing code (like filters), and it would "just work".</p>

<p>But I can't figure out how to override the constructor of a build-in type in a sub-type, as defining constructor in the subclass does not seem to help. I feel I'm missing something fundamental here about how Python built-in types work.</p>

<p>How should I approach this? I'm also open to alternatives that don't add too much complexity.</p>
