Reputation: 43
while "%%NOM%%" in outLine:
outLine = outLine.replace("%%NOM%%", nom, 1)
What does the double percent symbol mean ? What does it do ?
Upvotes: 3
Views: 7624
Reputation: 55
Yanis, in the context of your question then the answers from EMRIC and SHADOWTALKER are correct; however, I've seen it with a different use.AS example if you use %%time at the beining of a cell in a Jupyter notebook, then that command will print (after all commands inside the cell have executed) the time it took to execute the entire cell.
If you use it at the beginning of the cell without anything else, then you might receive the following message: UsageError: %%time is a cell magic, but the cell body is empty. Did you mean the line magic %time (single %)?
Wall time: 10.6 s
If you use a single percentage sign, like %time, it might return something like: Wall time: 0 ns
Upvotes: 2
Reputation: 2018
The "%%" does not have special meaning inside Python strings.
Probably this was a way to easily find a place in the input string to replace the "%%NOM%%" placeholder with a different value.
For the characters that have special meaning in Python strings, you can check Python docs on String literals
Upvotes: 0
Reputation: 13853
This is not Python-specific. Whoever wrote that code is using the string "%%NOM%%
as a placeholder, and using it to substitute the value of nom
.
Upvotes: 3