Skip to content

Instantly share code, notes, and snippets.

@Ajwah
Created July 3, 2015 22:31
Show Gist options
  • Save Ajwah/a5c1b87264be3fbe992d to your computer and use it in GitHub Desktop.
Save Ajwah/a5c1b87264be3fbe992d to your computer and use it in GitHub Desktop.
Usage of namedtuple to format a string
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))
@Ajwah
Copy link
Author

Ajwah commented Jul 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment