summaryrefslogtreecommitdiff
path: root/pypers/marelli/materiale/doctest_talk/more.txt
blob: 0e0b7fcdedecf82b276ce723c89e297912c385a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

Doctest and exceptions
--------------------------------------

<pre>

>>> from partecs_voting import vote_validator
>>> from partecs_voting.util import TheVoteIsClosedError
>>> validate = vote_validator(
...     choices = ["A", "B", "C"],
...     OpeningDate = "Sun Aug 29 06:00:00 2004", 
...     ClosingDate = "Sun Aug 30 22:00:00 2004")
>>> try: # assuming you run this after Aug 29 2004
...     validate("A")
... except TheVoteIsClosedError:
...     print "The vote is closed!"
The vote is closed!

</pre>

Real example
----------------------------------------------------------

<pre>

>>> from partecs_voting import make_ballot
>>> ballot=make_ballot(["A", "B"], [["A"], ["A"], ["B"]], "BordaBallot")
>>> print ballot.getresults()
ALL RESULTS:
A 2
B 1

</pre>