Raw strings as input from File?

Jon Clements joncle at googlemail.com
Wed Nov 25 07:58:57 EST 2009


On Nov 25, 3:31 am, Grant Edwards <inva... at invalid.invalid> wrote:
> On 2009-11-25, Rhodri James <rho... at wildebst.demon.co.uk> wrote:
>
>
>
> > On Tue, 24 Nov 2009 21:20:25 -0000, utabintarbo <utabinta... 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.
>
> It's, um, rewarding to see my recent set of instructions being
> followed.
>
> >> 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?
>
> ;)
>
> --
> Grant

Can't remember if this thread counts as "Edwards' Law 5[b|c]" :)

I'm sure I pinned it up on my wall somewhere, right next to
http://imgs.xkcd.com/comics/tech_support_cheat_sheet.png

Jon.



More information about the Python-list mailing list