User Input

Chris Angelico rosuav at gmail.com
Thu May 30 08:06:41 EDT 2013


On Thu, May 30, 2013 at 9:48 PM, Eternaltheft <eternaltheft at gmail.com> wrote:
> On Thursday, May 30, 2013 7:33:41 PM UTC+8, Eternaltheft wrote:
>> Hi, I'm having trouble oh how prompt the user to enter a file name and how to set up conditions. For example, if there's no file name input by the user, a default is returned
>
> Thanks for such a fast reply! and no im not using raw input, im just using input. does raw_input work on python 3?

No, on Python 3 just use input. In Python 2, input() is a dangerous
function that evaluates the entered text and raw_input() is the safe
one; in Python 3, raw_input got renamed to input(). Go ahead and use
input the way Fabio used raw_input.

By the way, there's a handy compact notation for what Fabio wrote:

filename = raw_input('file name: ') or 'your default'

Can be very handy!

ChrisA



More information about the Python-list mailing list