From Daryl.Tester at iocane.com.au Mon Mar 6 11:13:47 2006 From: Daryl.Tester at iocane.com.au (Daryl Tester) Date: Mon, 06 Mar 2006 20:43:47 +1030 Subject: [sapug] Python and Revision Control tagging Message-ID: <440C0B5B.3070402@iocane.com.au> A nice little Python idiom I picked up somewhere along the line. If you have your Python code under RCS/CVS style revision control, and you stick the following line in your module: __version__ = '$Name: $'[7:-2] or '$Revision: $'[11:-2] then the symbolic name (1st choice) or revision ID gets assigned to the __version__ attribute. The neat part lies in the string slicing; if a non-symbolic branch is checked out, then the '$Name: $' portion isn't set by RCS/CVS, and the [7:-2] portion of the string evaluates to empty causing the right half of the string to be evaluated instead. Well, I thought it was neat. -- Regards, Daryl Tester, IOCANE Pty. Ltd.