Skip to content

Commit 7d65e97

Browse files
authored
musician_lists and musician_dicts
1 parent 85fd012 commit 7d65e97

10 files changed

Lines changed: 23 additions & 23 deletions

python-operator-module/attrgetter_min_max.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Musician:
1010
group: str
1111

1212

13-
musicians_list = [
13+
musician_lists = [
1414
[1, "Brian", "Wilson", "Beach Boys"],
1515
[2, "Carl", "Wilson", "Beach Boys"],
1616
[3, "Dennis", "Wilson", "Beach Boys"],
@@ -22,7 +22,7 @@ class Musician:
2222

2323
group_members = []
2424

25-
for musician in musicians_list:
25+
for musician in musician_lists:
2626
group_members.append(Musician(*musician))
2727

2828
get_id = operator.attrgetter("id")

python-operator-module/attrgetter_selecting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Musician:
1010
group: str
1111

1212

13-
musicians_list = [
13+
musician_lists = [
1414
[1, "Brian", "Wilson", "Beach Boys"],
1515
[2, "Carl", "Wilson", "Beach Boys"],
1616
[3, "Dennis", "Wilson", "Beach Boys"],
@@ -22,7 +22,7 @@ class Musician:
2222

2323
group_members = []
2424

25-
for musician in musicians_list:
25+
for musician in musician_lists:
2626
group_members.append(Musician(*musician))
2727

2828
# Returning a single attribute.

python-operator-module/attrgetter_sorting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Musician:
1010
group: str
1111

1212

13-
musicians_list = [
13+
musician_lists = [
1414
[1, "Brian", "Wilson", "Beach Boys"],
1515
[2, "Carl", "Wilson", "Beach Boys"],
1616
[3, "Dennis", "Wilson", "Beach Boys"],
@@ -22,7 +22,7 @@ class Musician:
2222

2323
group_members = []
2424

25-
for musician in musicians_list:
25+
for musician in musician_lists:
2626
group_members.append(Musician(*musician))
2727

2828
# Sorting on a single attribute.

python-operator-module/calculate_modulus_serialize_deserialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def calculate_modulus(operand1, operand2):
1111
with open("calculate_modulus.pkl", "wb") as f:
1212
pickle.dump(calculate_modulus, f)
1313

14-
# De-serialize the function.
14+
# Deserialize the function.
1515

1616
with open("calculate_modulus.pkl", "rb") as f:
1717
unpickled_modulus = pickle.load(f)

python-operator-module/itemgetter_from_dictionary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import operator
22

3-
musicians = [
3+
musician_dicts = [
44
{"id": 1, "fname": "Brian", "lname": "Wilson", "group": "Beach Boys"},
55
{"id": 2, "fname": "Carl", "lname": "Wilson", "group": "Beach Boys"},
66
{"id": 3, "fname": "Dennis", "lname": "Wilson", "group": "Beach Boys"},
@@ -13,14 +13,14 @@
1313

1414
# Get a single element
1515
get_element_four = operator.itemgetter(4)
16-
print(get_element_four(musicians))
16+
print(get_element_four(musician_dicts))
1717

1818
# Get multiple elements
1919
get_elements_one_three_five = operator.itemgetter(1, 3, 5)
20-
print(get_elements_one_three_five(musicians))
20+
print(get_elements_one_three_five(musician_dicts))
2121

2222
# Get values within elements
2323
get_names = operator.itemgetter("fname", "lname")
2424

25-
for musician in get_elements_one_three_five(musicians):
25+
for musician in get_elements_one_three_five(musician_dicts):
2626
print(get_names(musician))

python-operator-module/itemgetter_in_min_max.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import operator
22

3-
musicians_list = [
3+
musician_lists = [
44
[1, "Brian", "Wilson", "Beach Boys"],
55
[2, "Carl", "Wilson", "Beach Boys"],
66
[3, "Dennis", "Wilson", "Beach Boys"],
@@ -12,6 +12,6 @@
1212

1313
get_id = operator.itemgetter(0)
1414

15-
print(max(musicians_list, key=get_id))
15+
print(max(musician_lists, key=get_id))
1616

17-
print(min(musicians_list, key=get_id))
17+
print(min(musician_lists, key=get_id))

python-operator-module/itemgetter_min_dictionary_value.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import operator
22

3-
musicians = [
3+
musician_dicts = [
44
{"id": 1, "fname": "Brian", "lname": "Wilson", "group": "Beach Boys"},
55
{"id": 2, "fname": "Carl", "lname": "Wilson", "group": "Beach Boys"},
66
{"id": 3, "fname": "Dennis", "lname": "Wilson", "group": "Beach Boys"},
@@ -12,4 +12,4 @@
1212

1313
get_lname = operator.itemgetter("lname")
1414

15-
print(min(musicians, key=get_lname))
15+
print(min(musician_dicts, key=get_lname))

python-operator-module/itemgetter_sorting_dictionaries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import operator
22

3-
musicians = [
3+
musician_dicts = [
44
{"id": 1, "fname": "Brian", "lname": "Wilson", "group": "Beach Boys"},
55
{"id": 2, "fname": "Carl", "lname": "Wilson", "group": "Beach Boys"},
66
{"id": 3, "fname": "Dennis", "lname": "Wilson", "group": "Beach Boys"},
@@ -11,4 +11,4 @@
1111
]
1212

1313
get_names = operator.itemgetter("lname", "fname")
14-
print(sorted(musicians, key=get_names, reverse=True))
14+
print(sorted(musician_dicts, key=get_names, reverse=True))
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import operator
22

3-
musicians_list = [
3+
musician_lists = [
44
[1, "Brian", "Wilson", "Beach Boys"],
55
[2, "Carl", "Wilson", "Beach Boys"],
66
[3, "Dennis", "Wilson", "Beach Boys"],
@@ -11,7 +11,7 @@
1111
]
1212

1313
get_id = operator.itemgetter(0)
14-
print(sorted(musicians_list, key=get_id, reverse=True))
14+
print(sorted(musician_lists, key=get_id, reverse=True))
1515

1616
get_elements_two_one = operator.itemgetter(2, 1)
17-
print(sorted(musicians_list, key=get_elements_two_one, reverse=True))
17+
print(sorted(musician_lists, key=get_elements_two_one, reverse=True))

python-operator-module/methodcaller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def get_full_name(self, last_name_first=False):
1515
return f"{self.fname} {self.lname}"
1616

1717

18-
musicians_list = [
18+
musician_lists = [
1919
[1, "Brian", "Wilson", "Beach Boys"],
2020
[2, "Carl", "Wilson", "Beach Boys"],
2121
[3, "Dennis", "Wilson", "Beach Boys"],
@@ -27,7 +27,7 @@ def get_full_name(self, last_name_first=False):
2727

2828
group_members = []
2929

30-
for musician in musicians_list:
30+
for musician in musician_lists:
3131
group_members.append(Musician(*musician))
3232

3333
# Print first name, then last name.

0 commit comments

Comments
 (0)