rfc: a self-editing script

garabik-news-2005-05 at kassiopeia.juls.savba.sk garabik-news-2005-05 at kassiopeia.juls.savba.sk
Sat Oct 10 12:18:53 CEST 2009


Steven D'Aprano <steve at remove-this-cybersource.com.au> 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 the file, something 
> like this:

...

> # ==================================================
> # ===      Version number history goes here.     ===
> # === DO NOT insert any code after this point!!! ===
> # ==================================================
> # 1.0.1
> # 1.0.2a
> # 1.0.2
> # 1.0.5
> 
> 
> This has the added advantage that you can track the updates made to the 
> version number.
> 

And my experience taught me that is pays off to include also date (and
time) of each change, preferably in the RFC 3339 format. Priceless when
you hunt for an unnoticed bug or a crash that happened sometime in the
past...

e.g.:

# 1.0.1 2006-08-07 12:34:56-06:00
# 1.0.2a 2006-08-08 13:35:57-07:00
# 1.0.2 2006-08-10 01:04:56-06:00

etc...

-- 
 -----------------------------------------------------------
| Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__    garabik @ kassiopeia.juls.savba.sk     |
 -----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!



More information about the Python-list mailing list