def parse(text):
        """Try to parse into a number.

        Return:
            the number (int or float) if successful; otherwise None.
        """
        try:
            return int(text)
        except ValueError:
            try:
                amount = float(text)
                assert not isnan(amount) and not isinf(amount)
                return amount
            except (ValueError, AssertionError):
                return None
Try to parse into a number.

        Return:
            the number (int or float) if successful; otherwise None.