|
1 | 1 | # Submitted by Marius Becker
|
2 | 2 | # Updated by Amaras
|
3 | 3 |
|
4 |
| -import sys |
| 4 | + |
5 | 5 | from random import shuffle
|
6 | 6 | from copy import copy
|
7 | 7 | from string import ascii_uppercase, ascii_lowercase
|
8 | 8 |
|
9 | 9 |
|
10 | 10 | def main():
|
11 |
| - # Set this to however many men and women you want |
12 |
| - try: |
13 |
| - num_pairs = int(sys.argv[1]) |
14 |
| - except (IndexError, ValueError): |
15 |
| - # If you either did not set how many pairs you wanted or you |
16 |
| - # did not set it as a number, use default value of 5 |
17 |
| - num_pairs = 5 |
18 |
| - |
19 |
| - # There are only 26 possible names for each sex |
20 |
| - if num_pairs > 26: |
21 |
| - print("You can't have more than 26 pairs.") |
22 |
| - return |
| 11 | + # Set this to however many men and women you want, up to 26 |
| 12 | + num_pairs = 5 |
23 | 13 |
|
24 | 14 | # Create all Person objects
|
25 | 15 | men = [Person(name) for name in ascii_uppercase[:num_pairs]]
|
@@ -108,15 +98,16 @@ def pick_preferred(self):
|
108 | 98 | self.partner = person
|
109 | 99 | break
|
110 | 100 |
|
111 |
| - # Rejected candidates don't get a second chance. :( |
| 101 | + # Rejected candidates don't get a second chance |
112 | 102 | self.candidates.clear()
|
113 | 103 |
|
114 | 104 | @property
|
115 | 105 | def partner(self):
|
116 | 106 | return self._partner
|
117 | 107 |
|
118 |
| - # This allows one to change both self.partner and person.partner |
119 |
| - # with the simple call: "self.partner = person" |
| 108 | + # The call self.partner = person sets self._partner as person |
| 109 | + # However, since engagement is symmetrical, self._partner._partner |
| 110 | + # (which is then person._partner) also needs to be set to self |
120 | 111 | @partner.setter
|
121 | 112 | def partner(self, person):
|
122 | 113 | """Set a person as the new partner and sets the partner of that
|
|
0 commit comments