Converting a Shell Script to run under Python

Gordon McMillan gmcm at hypernet.com
Tue Dec 7 14:31:54 EST 1999


D'Arcy J.M. Cain wrote:

> Magnus L. Hetland <mlh at vier.idi.ntnu.no> wrote:
[exposes unforgivable ignorance of shutil <wink>]

> > open("file3","w").write(open("file1").read())
> 
> > though that is probably not a good idea. I guess I would rather
> > do
> 
> Why don't you find this a good idea?  It's pretty much a Python
> paradigm as far as I'm concerned.  I suppose a module with this
> in it would make it easier to read but I don't know that I care
> for the extra work and overhead.

Although I've been known to do this, I can think of 2 reasons 
why you shouldn't make a habit of it.

First, an IOException will be hard to figure out. Second, the 
same code in JPython will leave you with a mess on your 
hands, until GC wakes up and cleans it up for you. I happily 
ignore the second one all the time, too.

make-Barry-clean-it-up-ly y'rs

- Gordon




More information about the Python-list mailing list