def input_object(prompt_text, cast = None, default = None,
                 prompt_ext = ': ', castarg = [], castkwarg = {}):
    """Gets input from the command line and validates it.
    
    prompt_text
        A string. Used to prompt the user. Do not include a trailing
        space.
        
    prompt_ext
        Added on to the prompt at the end. At the moment this must not
        include any control stuff because it is send directly to
        raw_input
        
    cast
        This can be any callable object (class, function, type, etc). It
        simply calls the cast with the given arguements and returns the 
        result. If a ValueError is raised, it
        will output an error message and prompt the user again.

        Because some builtin python objects don't do casting in the way
        that we might like you can easily write a wrapper function that
        looks and the input and returns the appropriate object or exception.
        Look in the cast submodule for examples.
        
        If cast is None, then it will do nothing (and you will have a string)
        
    default
        function returns this value if the user types nothing in. This is
        can be used to cancel the input so-to-speek
        
    castarg, castkwarg
        list and dictionary. Extra arguments passed on to the cast.
    """
    while True:
        stdout.write(prompt_text)
        value = stdout.raw_input(prompt_ext)
        if value == '': return default
        try:
            if cast != None: value = cast(value, *castarg, **castkwarg)
        except ValueError as details:
            if cast in NICE_INPUT_ERRORS: # see comment above this constant
                stderr.write(ERROR_MESSAGE % (NICE_INPUT_ERRORS[cast] % details))
            else: stderr.write(ERROR_MESSAGE % (DEFAULT_INPUT_ERRORS % str(details)))
            continue
        return value