[Tutor] escape codes and filenames

Mallett, Roger rmallett@rational.com
Sat, 25 Nov 2000 11:38:09 -0800


I have a series of files that need to be opened.  Several of the files start
with characters normally reserved as Escape codes.

Using
	for filename in filelist:
		x=open(filename,'r')

fails anytime anypart of *filename* contains a "\<escape_code>" sequence.
For example:  if filename is set to "c:\trash.txt", then the file will not
open with the open command above because the "\t" is perceived as an escape
code.

I have therefore written code to scrub each instance of filename to ensure
no escape sequences exist before the open command is executed.

Is there another way to handle this?  I found information about *raw*
commands in the python documentation but couldn't figure out how to work it.

Any ideas of how this type of situation should be handled?

Thank you for your help,

Roger Mallett