Add __int__ function for attributes.

This will fail for some types that aren't necessarily numeric
(or strings containing numbers), but that is likely expected behavior
anyway.