Re: how to write a line in a text file

2005-08-10 Thread James Dennett
Calvin Spealman wrote: > On 7/31/05, James Dennett <[EMAIL PROTECTED]> wrote: > >>Peter Hansen wrote: >> >> >>>Steven D'Aprano wrote: >>> >>>Given that ZODB and PySQLite are simply Python extension modules, which >>>get bundled by your builder tool and are therefore installed >>>transparently alon

Re: how to write a line in a text file

2005-08-10 Thread Jeff Schwab
Calvin Spealman wrote: > On 7/31/05, James Dennett <[EMAIL PROTECTED]> wrote: > >>Peter Hansen wrote: >> >> >>>Steven D'Aprano wrote: >>> >>>Given that ZODB and PySQLite are simply Python extension modules, which >>>get bundled by your builder tool and are therefore installed >>>transparently alon

Re: how to write a line in a text file

2005-08-10 Thread Calvin Spealman
On 7/31/05, James Dennett <[EMAIL PROTECTED]> wrote: > Peter Hansen wrote: > > > Steven D'Aprano wrote: > > > > Given that ZODB and PySQLite are simply Python extension modules, which > > get bundled by your builder tool and are therefore installed > > transparently along with your app by your ins

Re: how to write a line in a text file

2005-07-31 Thread James Dennett
Peter Hansen wrote: > Steven D'Aprano wrote: > >> On Wed, 27 Jul 2005 04:26:31 +, Andrew Dalke wrote: >> >>> This isn't 1970. Why does your app code work directly with >>> files? Use a in-process database library (ZODB, SQLLite, >>> BerkeleyDB, etc.) to maintain your system state and let th

Re: how to write a line in a text file

2005-07-27 Thread Peter Hansen
Steven D'Aprano wrote: > On Wed, 27 Jul 2005 04:26:31 +, Andrew Dalke wrote: >>This isn't 1970. Why does your app code work directly with >>files? Use a in-process database library (ZODB, SQLLite, >>BerkeleyDB, etc.) to maintain your system state and let the >>library handle transactions for

Re: how to write a line in a text file

2005-07-27 Thread Steven D'Aprano
On Wed, 27 Jul 2005 04:26:31 +, Andrew Dalke wrote: > This isn't 1970. Why does your app code work directly with > files? Use a in-process database library (ZODB, SQLLite, > BerkeleyDB, etc.) to maintain your system state and let the > library handle transactions for you. And when users are

Re: how to write a line in a text file

2005-07-26 Thread Andrew Dalke
> [EMAIL PROTECTED] wrote: >> Well, it's what (R)DBMS are for, but plain files are not. Steven D'Aprano wrote: > This isn't 1970, users expect more from professional > programs than "keep your fingers crossed that nothing > bad will happen". That's why applications have multiple > levels of und

Re: how to write a line in a text file

2005-07-26 Thread Steven D'Aprano
[EMAIL PROTECTED] wrote: > Tue, Jul 26, 2005 at 01:41:36PM +1000, Steven D'Aprano пишет: > >>Long ago, when dinosaurs roamed the Earth, (a.k.a. >>"before OS X on the Macintosh") Apple suggested a bit >>of Pascal code for safely updating a file: >> >>http://developer.apple.com/documentation/mac/F

Re: how to write a line in a text file

2005-07-25 Thread en.karpachov
Tue, Jul 26, 2005 at 01:41:36PM +1000, Steven D'Aprano пишет: > Long ago, when dinosaurs roamed the Earth, (a.k.a. > "before OS X on the Macintosh") Apple suggested a bit > of Pascal code for safely updating a file: > > http://developer.apple.com/documentation/mac/Files/Files-25.html#MARKER-9-16

Re: how to write a line in a text file

2005-07-25 Thread Steven D'Aprano
Wade wrote: > Steven D'Aprano wrote: > >>I'm usually opposed to creeping featuritis in programming languages ("it >>would be really cool if Python had a built-in command to do my entire >>application") but safe over-writing of files does cry out for a "batteries >>included" approach: > > > > H

Re: how to write a line in a text file

2005-07-25 Thread Wade
Steven D'Aprano wrote: >I'm usually opposed to creeping featuritis in programming languages ("it >would be really cool if Python had a built-in command to do my entire >application") but safe over-writing of files does cry out for a "batteries >included" approach: How about the fileinput module?

Re: how to write a line in a text file

2005-07-25 Thread Steven D'Aprano
On Mon, 25 Jul 2005 20:51:42 +0100, Steve Holden wrote: > In Python you can use a text file's readlines() method to build a list > of all the lines in a file. That makes it quite easy to change numbered > lines. Having modified the file's content in memory you can then create > a new file using

Re: how to write a line in a text file

2005-07-25 Thread Dan Sommers
On 25 Jul 2005 12:57:55 -0700, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > A recipe is > * open your file for reading: f = open('filename.txt', 'r') > * read all lines in a list: content = f.readlines() > * close the file: f.close() > * set the third element in the list to something else: con

Re: how to write a line in a text file

2005-07-25 Thread nephish
Gee whiz, so easy. thanks. Never thought about just changing it while it was read then re-writing it. that will be just fine. these files are only 9 lines long. thanks again ! -- http://mail.python.org/mailman/listinfo/python-list

Re: how to write a line in a text file

2005-07-25 Thread [EMAIL PROTECTED]
A recipe is * open your file for reading: f = open('filename.txt', 'r') * read all lines in a list: content = f.readlines() * close the file: f.close() * set the third element in the list to something else: content[2] = 'Blahdiblah' * re-open the file for writing: f = open('filename.txt', 'w') * wr

Re: how to write a line in a text file

2005-07-25 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Hey there, > kinda newbie question here. > i know how to read the lines of a txt file. > i know how to write a txt file. > > but how do i overwrite a line value with another value ? > > i mean, how do go to, say, line 3 of a text file and replace > what is written on li

how to write a line in a text file

2005-07-25 Thread nephish
Hey there, kinda newbie question here. i know how to read the lines of a txt file. i know how to write a txt file. but how do i overwrite a line value with another value ? i mean, how do go to, say, line 3 of a text file and replace what is written on line 3 with something else? thanks <>< --