문제

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!

도움이 되었습니까?

해결책

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

다른 팁

This is a result of subversion's keyword substitution (originally CVS's). Yes, it works with all files, not just python source code.

This is called "keyword substitution", and variants of this idea are implemented in a number of version control systems, like RCS, CVS, and Subversion. Given that, you can now easily search the web for details.

It's not python specific.

Some version control systems (RCS, CVS, and SVN at least) automatically insert the revision number and last modified date of the file with those special variables.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top