On Tue, Oct 18, 2011 at 12:58 PM, amt <0101...@gmail.com> wrote: > Greetings! I got stuck at an exercise from the book learn python the hard > way about raw_input function.(exercise 11.2) > > After reading from docs.python.org I found out that this function can > perform standard output without a trailing newline.Also it can take an input > line, convert it as a string( stripping a trailing newline) and return it. > > > The exercise question is : Can you find other ways to use it? > <snip> Are there any other ways of using it? If yes can you please give me > a detailed example so I can understand. >
The most common other way that I use it is on Windows. If you want the terminal to stay open after your program has finished executing you can do something like this: # print_odds.py # Prints some odd numbers for x in xrange(1, 20, 2): print x raw_input("Press <enter> to continue") I've done similar things when debugging in a loop - instead of using print, I use raw_input and it lets me see the output and waits for me to hit enter to continue the loop. HTH, Wayne
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor