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