0

I have written a parser in Python that takes a tracklist of played songs in (for example) a podcast, and formats the tracks correctly for scrobbling to the last.fm website.

Because some tracklists feature odd tracks or sometimes tracks may be parsed incorrectly I wish to ask a user to correct the parsed input. I know of the raw_input() function, but that doesn't let me print a default text (like the complete parsed tracklist), meaning users would have to copy/paste the entire list before correcting.

Is there a way to print a 'suggestion' to use in the raw_input()?

Geert Smelt
  • 987
  • 1
  • 7
  • 19
  • If you are making a console-based application, a common approach is to create a temporary file, drop into an external text editor, and resume once the user exits it. This is how one enters commit messages in Git, for example. – Vasiliy Faronov Jun 22 '12 at 20:21

1 Answers1

0

Not sure if this is exactly what you're trying to do, but if you want to get line-by-line input and have a default value, this is what I did for a similar problem:

def get_input(prompt, default):
    result = raw_input('%s [%s]:' % (prompt, default))
    result = result or default
    return result
brjaga
  • 389
  • 1
  • 7
  • Thanks for the reply, I haven't been able to check here for a while. I actually would like to just 'suggest' a block of text in which the user can make changes before finalizing them. I will try out your method to see if it works and report back. – Geert Smelt Jun 28 '12 at 12:25