def int_cast_or_len(i):
    """
  >>> int_cast_or_len(range(10))
  10
  >>> int_cast_or_len('90 foo')
  6
  >>> int_cast_or_len('90')
  90

  """
    try:
        return int(i)
    except ValueError:
        return len(i)
    except TypeError:
        return len(i)
