[Tutor] raw_input a directory path

Hugo Arts hugo.yoshi at gmail.com
Fri May 14 02:52:50 CEST 2010


On Fri, May 14, 2010 at 2:37 AM, Dave Angel <davea at dejaviewphoto.com> wrote:
> The other approach is to have the user type in the text according to some
> escaping language (like the one used for literals), and explicitly decode
> that after the raw_input().  I thought there was a way in the stdlib, but I
> can't seem to find it right now.
>

the str.decode method has a 'string_escape' encoding:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print raw_input('prompt: ').decode('string_escape')
prompt: hello\nhello
hello
hello
>>>

Hugo


More information about the Tutor mailing list