I'm not sure about the Python specifics, but if put the string $Revision$ into your file somewhere and you have enable-auto-props=true in your SVN config, it'll get rewritten to something like $Revision: 144$. You could then parse this in your script.
There are a number of property keywords you can use in this way.
This won't have any overhead, e.g. querying the SVN repo, because the string is hard-coded into your file on commit or update.
I'm not sure how you'd parse this in Python but in PHP I'd do:
$revString = '$Revision: 144$';
if(preg_match('/: ([0-9]+)$/', $revString, $matches) {
echo 'Revision is ' . $matches[1];
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…