Raw Strings (I Think)

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Jul 28 07:05:48 EDT 2008

En Thu, 24 Jul 2008 12:02:00 -0300, Lanny <lanny at freshells.ch> escribió:

> I've used glob.glob to get a list of files in a directory
> and now I want to use os.system to execute one of
> those files, the problem is that python automatically
> puts a escape charater infront of the back slashes
> so the os.system gets X:\\####\\####\\ and is useless,
> I think I need to convert my string to a raw string but
> I don't know how.

Those \\ represent a SINGLE character. That is, they LOOK duplicated in code and when you use repr(...) but it's actually a single backslash:

>>> path = "X:\\abc"
>>> path
>>> print path
>>> len(path)

Probably you have another issue - please post a short but complete failing code...

Gabriel Genellina

More information about the Python-list mailing list