Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of $ in a string?

I came along this

__date__ = "$Date: 2011/06$"

and found this in the docs

  • $$ is an escape; it is replaced with a single $.
  • $identifier names a substitution placeholder matching a mapping key of "identifier". By default, "identifier" must spell a Python identifier. The first non-identifier character after the $ character terminates this placeholder specification.
  • ${identifier} is equivalent to $identifier. It is required when valid identifier characters follow the placeholder but are not part of the placeholder, such as "${noun}ification".

but I don't understand it.

Could someone explain in plain english what's the $ for and give some examples preferably?

like image 786
embert Avatar asked Mar 26 '14 18:03

embert


People also ask

What does the saying on a string mean?

Definition of have (someone) on a string informal. : to be able to make (someone) do anything one wants.

What does living on a string mean?

To feel happy and confident that everything will work out in one's favor and/or that one is in complete control.

What are two meanings of string?

Definition of string (Entry 1 of 3) 1a : a cord usually used to bind, fasten, or tie —often used attributively a string bag. b : something that resembles a string garnished with potato strings. 2a archaic : a cord (such as a tendon or ligament) of an animal body. b : a plant fiber (such as a leaf vein)

What is the meaning of string in short?

string noun (ROPE) B2 [ C or U ] (a piece of) strong, thin rope made by twisting very thin threads together, used for fastening and tying things: a package tied with string. a ball/piece of string.


1 Answers

To Python, those dollar signs mean nothing at all. Just like the 'D' or 'a' that follow, the dollar sign is merely a character in a string.

To your source-code control system, the dollar signs indicate a substitution command. When you check out a new copy of your source code, that string is replaced with the timestamp of the last committed change to the file.

Reference:

  • http://svnbook.red-bean.com/en/1.6/svn.advanced.props.special.keywords.html
  • http://www.badgertronics.com/writings/cvs/keywords.html
like image 141
Robᵩ Avatar answered Nov 10 '22 05:11

Robᵩ