Raw strings as input from File?

Rhodri James rhodri at wildebst.demon.co.uk
Tue Nov 24 20:11:29 EST 2009


On Tue, 24 Nov 2009 21:20:25 -0000, utabintarbo <utabintarbo at gmail.com>  
wrote:

> On Nov 24, 3:27 pm, MRAB <pyt... at mrabarnett.plus.com> wrote:
>>
>> .readlines() doesn't change the "\10" in a file to "\x08" in the string
>> it returns.
>>
>> Could you provide some code which shows your problem?
>
> Here is the code block I have so far:
> for l in open(CONTENTS, 'r').readlines():
>     f = os.path.splitext(os.path.split(l.split('->')[0]))[0]
>     if f in os.listdir(DIR1) and os.path.isdir(os.path.join(DIR1,f)):
>         shutil.rmtree(os.path.join(DIR1,f))
>         if f in os.listdir(DIR2) and os.path.isdir(os.path.join(DIR2,f)):
>             shutil.rmtree(os.path.join(DIR2,f))

Ahem.  This doesn't run.  os.path.split() returns a tuple, and calling  
os.path.splitext() doesn't work.  Given that replacing the entire loop  
contents with "print l" readily disproves your assertion, I suggest you  
cut and paste actual code if you want an answer.  Otherwise we're just  
going to keep saying "No, it doesn't", because no, it doesn't.

> A minimally obfuscated line from the log file:
> K:\sm\SMI\des\RS\Pat\10DJ\121.D5-30\1215B-B-D5-BSHOE-MM.smz->/arch_m1/
> smi/des/RS/Pat/10DJ/121.D5-30\1215B-B-D5-BSHOE-MM.smz ; t9480rc ;
> 11/24/2009 08:16:42 ; 1259068602
>
> What I get from the debugger/python shell:
> 'K:\\sm\\SMI\\des\\RS\\Pat\x08DJQ.D5-30Q5B-B-D5-BSHOE-MM.smz->/arch_m1/
> smi/des/RS/Pat/10DJ/121.D5-30/1215B-B-D5-BSHOE-MM.smz ; t9480rc ;
> 11/24/2009 08:16:42 ; 1259068602'

When you do what, exactly?

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list