Python doesn't see the directories I create

Marc 'BlackJack' Rintsch bj_666 at
Thu Aug 30 10:58:30 CEST 2007

On Thu, 30 Aug 2007 04:30:50 -0400, mr_gadget wrote:

> C:\>python -c "import os; print os.path.exists('C:\enhancement\rawfiles')"
> False
> C:\>python -c "import os; print os.path.exists('C:\\enhancement\\rawfiles')"
> True

The backward slash has a special meaning in string literals.  It is used
to escape special character.  One such sequence is '\r' which is *one*
character, namely the return character.  To insert *one* backslash it has
to be protected by another backslash or the string literal may be prefixed
by an 'r' to tell the compiler that backslashes have no special meaning in
that raw string literal.

In [23]: len('\r')
Out[23]: 1

In [24]: len('\\')
Out[24]: 1

In [25]: len(r'\r')
Out[25]: 2

In [26]: len(r'\\')
Out[26]: 2

	Marc 'BlackJack' Rintsch

More information about the Python-list mailing list