summaryrefslogtreecommitdiff
path: root/pypers/marelli/materiale/doctest_talk/more.txt
diff options
context:
space:
mode:
authormichele.simionato <devnull@localhost>2007-12-02 11:13:11 +0000
committermichele.simionato <devnull@localhost>2007-12-02 11:13:11 +0000
commit20ce686b0193d67ea56823a30551140f88b3aee1 (patch)
tree76015e7e4dc0b000bd857a2bdba6fb7976ac29a7 /pypers/marelli/materiale/doctest_talk/more.txt
parentf08f40335ad7f0ac961f25dabaaed34c4d4bcc44 (diff)
downloadmicheles-20ce686b0193d67ea56823a30551140f88b3aee1.tar.gz
Commited all py papers into Google code
Diffstat (limited to 'pypers/marelli/materiale/doctest_talk/more.txt')
-rwxr-xr-xpypers/marelli/materiale/doctest_talk/more.txt33
1 files changed, 33 insertions, 0 deletions
diff --git a/pypers/marelli/materiale/doctest_talk/more.txt b/pypers/marelli/materiale/doctest_talk/more.txt
new file mode 100755
index 0000000..0e0b7fc
--- /dev/null
+++ b/pypers/marelli/materiale/doctest_talk/more.txt
@@ -0,0 +1,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>