Created
July 3, 2015 22:31
-
-
Save Ajwah/a5c1b87264be3fbe992d to your computer and use it in GitHub Desktop.
Usage of namedtuple to format a string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Score = namedtuple("Score", 'Id W L D') | |
p1s = Score(p1, 1, 0, 0) | |
p2s = Score(p2, 0, 1, 0) | |
c.execute("update players set wins = wins + {0.W}, losses = losses + {0.L}, draws = draws + {0.D} where id={0.Id}".format(p1s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source:
http://grokbase.com/t/python/python-ideas/092ajn841h/string-formatting-and-namedtuple