[Tutor] Re: [Python-Help] why do i need to surround file names in inputs with quotes?
Alex Martelli
python-help@python.org
Mon, 8 Apr 2002 18:02:06 +0200
On Monday 08 April 2002 05:57 pm, Tom Churm wrote:
> hi,
>
> i've found & adapted the following simple python script that copies one
> text file to another text file. the script works o.k., but only when i
> enter the name of the text file (both original, and the name of the new
> text file) surrounded by "double quotes".
The built-in function called input wants the user to enter a Python
expression -- and the Python expression for a string needs quotes
(single or double ones, indifferently).
If you just want a string, not an expression, use raw_input instead, i.e.:
> a = input('Type name of file to copy surrounded by doublequotes')
> b = input('Type name of new file surrounded by doublequotes')
change to:
a = raw_input("Type name of file to copy: ")
b = raw_input("Type name of new file: ")
Note: please don't crosspost as widely as that -- just python-help
would be fine, thanks!
Alex