def prompt(name, default=None):
    """
    Grab user input from command line.

    :param name: prompt text
    :param default: default value if no input provided.
    """

    prompt = name + (default and ' [%s]' % default or '')
    prompt += name.endswith('?') and ' ' or ': '
    while True:
        try:
            rv = raw_input(prompt)
        except NameError:
            rv = input(prompt)
        if rv:
            return rv
        if default is not None:
            return default
def prompt ( name , default = None ) : prompt = name + ( default and ' [%s]' % default or '' ) prompt += name . endswith ( '?' ) and ' ' or ': ' while True : try : rv = raw_input ( prompt ) except NameError : rv = input ( prompt ) if rv : return rv if default is not None : return default
Grab user input from command line.

    :param name: prompt text
    :param default: default value if no input provided.