am I stupid 
Author Message
 am I stupid

Or,

How do I put a backslash as the last character in a raw string.

See the text below, cut from idle,

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
IDLE 0.5 -- press F1 for help
 >>> a='hello\\'
 >>> print a
hello\
 >>> a=r'helo\'
SyntaxError: invalid token
 >>> a=r'hello\\'
 >>> print a
hello\\
 >>>

Note the line before SynaxError

John Carter



Sat, 09 Nov 2002 03:00:00 GMT  
 am I stupid

Quote:

> How do I put a backslash as the last character in a raw string.

read the fine FAQ ;-)

    http://www.python.org/doc/FAQ.html#6.29
    Why can't raw strings (r-strings) end with a backslash?

(summary: raw strings are parsed exactly as standard strings,
it's just that instead of translating escape sequences to character
codes, they're stored as is in the output string.  the faq entry
shows you some ways to get around this little problem...)

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->



Sat, 09 Nov 2002 03:00:00 GMT  
 am I stupid
Raw strings cannot end in a single backslash.
Quote:

> Or,

> How do I put a backslash as the last character in a raw string.

> See the text below, cut from idle,

> Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> IDLE 0.5 -- press F1 for help
>  >>> a='hello\\'
>  >>> print a
> hello\
>  >>> a=r'helo\'
> SyntaxError: invalid token
>  >>> a=r'hello\\'
>  >>> print a
> hello\\

> Note the line before SynaxError

> John Carter




Wed, 13 Nov 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. I am a stupid newbie.

2. REPOST: I am a stupid forger

3. I am clinically stupid. (fastcgi.rb bug)

4. Just starting -- am I stupid? (new and initialize)

5. Maybe I am just stupid... :(

6. REPOST: I am a stupid forger

7. Is Fortran great or am I stupid?

8. I am to stupid to embedd python - pls help

9. Does python suck or I am just stupid?

10. I am so stupid or Reading boot sectors, fixed!

11. Stupid newb question: What am I doing wrong?

12. Stupid question I am afraid, but I could use a pointer or two

 

 
Powered by phpBB® Forum Software