Steve Holden wrote:

You need to read up on string literals is all. "\\" is simply the
literal representation of a string containing a single backslash. This
comes about because string literals are allowed to contain special
"escape sequences" which are introduced by a backslash; since this gives
the backslash a special meaning in string literals we also have to use
an escape sequence ("\\") to represent a backslash.

In practice you will find that

a) Many Windows APIs (but not the command line) are just as happy with a
forward slash as a backslash to separate file path components; and

b) The best practice is to build filenames using the routines provided
in the os.path module, which guarantees to give results correct for the
current platform.

regards
 Steve
Basic sys functions brought out the \ separator for paths.

What am I missing here? Looks OK to me.


>>> abc=r'xyz\\'
>>> abc
'xyz\\\\'
>>> print abc
xyz\\
>>> abc.replace(r'\',r'z')
        
SyntaxError: invalid syntax
>>> abc
'xyz\\\\'
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to