> 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
> 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
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
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
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(