Re: [Tutor] This Deletes All my Files

2005-02-04 Thread Alan Gauld
> I've tried this and I cannot figure out why this does not work. So what happens? And how are you closing the file? > open(item,'w').write(open(item,'r').read().replace(' ','')) I can't see the obvious flaw, but using anonymous files(*) is not a good idea IMHO. (*)Unlike anonymous functions

Re: [Tutor] This Deletes All my Files

2005-02-04 Thread Alan Gauld
> So the first argument evaluated is "self" ... and in your case "self" is > "open(item, 'w')" so the first thing your line does is opening for > writing the file named by "item" and as "w" empty the file ... you can > read it afterward, it will be empty ! Ah! well spotted Pierre, I hadn't noticed

Re: [Tutor] This Deletes All my Files

2005-02-04 Thread Max Noel
On Feb 4, 2005, at 06:39, Chad Crabtree wrote: I've tried this and I cannot figure out why this does not work. I figure this has something to do with order of operations. I figured someone would know exactly why it doesn't work. Wouldn't this start inside parens then from left to right? open(ite

Re: [Tutor] This Deletes All my Files

2005-02-04 Thread Pierre Barbier de Reuille
Ok, so in Python, arguments are evaluated first, left to right ! The outer-most function used in your sample is : file.write(self, filename, mode) So the first argument evaluated is "self" ... and in your case "self" is "open(item, 'w')" so the first thing your line does is opening for writing th

[Tutor] This Deletes All my Files

2005-02-03 Thread Chad Crabtree
I've tried this and I cannot figure out why this does not work. I figure this has something to do with order of operations. I figured someone would know exactly why it doesn't work. Wouldn't this start inside parens then from left to right? open(item,'w').write(open(item,'r').read().replace(