Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python headers -- What is the purpose of the $ ( dollar sign ) encapsulation?

Apologies in advance, this is something that I really figured I could find on the web, but I was having troubles.

In Python, in the header portion, I see that sometimes people will wrap their literals with a dollar sign ( $ ). It seems, judging from examples, that this is a pointer to fill in information that is automatically updated (maybe via source control?), but I do not understand how it works.

For instance:

__version__ = '$Revision: 4799 $'.split()[1]
__date__ = '$Date: 2006-09-25 11:09:02 -0400 (Mon, 25 Sep 2006) $'.split()[1]
__author__ = 'John Doe FIX: put in the authors name'

is an example that I found at ( Python Example Documentation Template ). So the $ is wrapped around the version (which will alter over time), and the date (which will also alter). Assuming it is some sort of pointer to always capture up-to-date information regarding the version, date, etc., can someone point me to how this works? Which source control software use this syntax? Is it the same across languages?

Thank you!

like image 720
Mike Williamson Avatar asked Apr 12 '13 23:04

Mike Williamson


People also ask

What is the dollar sign in Python?

That dollar sign means: we're in the system shell, i.e the program that you're put into as soon as you open the Terminal app. The dollar sign is often the symbol used to signify where you can begin typing in commands (you should see a blinking cursor there).

How do you add a dollar sign in python markdown?

In markdown editors such as GitHub , or Jupyter notebook , with MathJax available, you can use double backslash and a dollar sign together to show any amount or range of amount in the dollar. Note that, in StackExchange or any StackOverflow related site, a single backslash is enough.


1 Answers

This isn't specific to Python, it's something used by source control systems, going back to RCS and CVS.

See CVS Keywords for a list of the CVS syntax. While few people use CVS nowadays, many of the source control systems people do use (most notably, subversion) handle CVS syntax or a slight variation of it. (And some people also create build scripts that do similar substitutions at build time rather than checkin time.)

like image 91
abarnert Avatar answered Oct 08 '22 07:10

abarnert