rfc: a self-editing script

2009-10-12 Thread gb345
The following fragment is from a tiny maintenance script that, among other things, edits itself, by rewriting the line that ends with '### REPLACE'. ## import re import fileinput LAST_VERSION = 'VERSION 155' ### REPLACE ser

Re: rfc: a self-editing script

2009-10-10 Thread gb345
In <0059c2b1$0$26930$c3e8...@news.astraweb.com> Steven D'Aprano writes: >But if you absolutely have to write to the program file... No, don't have to, beyond the urge to satisfy a very idiosyncratic aesthetic imperative... >then append your >data to the end of the file (as a comment) and late

Re: rfc: a self-editing script

2009-10-10 Thread garabik-news-2005-05
Steven D'Aprano wrote: ... > But if you absolutely have to write to the program file, then append your > data to the end of the file (as a comment) and later read that, rather > than modifying the actual code in place. That is, you fetch the > LAST_VERSION by reading the last non-empty line in

Re: rfc: a self-editing script

2009-10-10 Thread Steven D'Aprano
On Fri, 09 Oct 2009 23:30:16 +, gb345 wrote: > The following fragment is from a tiny maintenance script that, among > other things, edits itself, by rewriting the line that ends with '### > REPLACE'. > > ## > > import re > i