Ballot

class ballotbox.ballot.BallotBox(method=None, data={}, *args, **kwargs)
add_vote(vote)

The parameter ‘vote’ can be either a single string representing a candidate, or a dictionary representing a set of preferences cast by a single voter.

add_votes(vote, count)

For a unique vote, add the number of times it was voted for.

batch_votes(votes)

This method differs from the add_votes method in that there is more than one vote being cast, each with potentially many vote counts.

The parameter ‘votes’ should be a list of tuples:
[(vote1, count1), (vote2, count2), ... (voten, countn)]
get_total_votes()

Count all votes cast for all candidates.

get_winner(*args, **kwargs)

Determine the winner, if one exists.

This is a wrapper for the method of the same name on the IVotingMethod implementation class.

has_key(key)

D.has_key(k) -> True if D has a key k, else False.

items()

D.items() -> list of D’s (key, value) pairs, as 2-tuples.

iteritems()

D.iteritems() -> an iterator over the (key, value) items of D.

iterkeys()

D.iterkeys() -> an iterator over the keys of D.

keys()

D.keys() -> list of D’s keys.

update(vote)

D.update(E, **F) -> None. Update D from dict/iterable E and F.

  • If E has a .keys() method, does: for k in E: D[k] = E[k]
  • If E lacks .keys() method, does: for (k, v) in E: D[k] = v

In either case, this is followed by: for k in F: D[k] = F[k]

Previous topic

Interfaces

Next topic

Single-Winner

This Page