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