Writing to a file
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sat Mar 26 07:51:50 EDT 2011
On Sat, 26 Mar 2011 14:49:31 +1300, Gregory Ewing wrote:
> jyoung79 at kc.rr.com wrote:
>
>>>>>import os
>>>>>os.system('echo "Testing a... b... c..." > "~/Desktop/test2.txt"')
>
> This is like going out the back door, getting a ladder out of the shed
> and climbing through your bedroom window to get into bed at night,
> instead of just using the stairs.
>
> Use open/write/close. It's much more direct and efficient.
I would say the analogy is more like calling the local handyman to come
to your house and get the ladder for you.
--
Steven
More information about the Python-list
mailing list