Dead Poets Society1 is a 1989 American drama film directed by Peter Weir2, written by Tom Schulman3, and starring Robin Williams4. Set in 1959 at the fictional elite conservative boarding school Welton Academy, it tells the story of an English teacher who inspires his students through his teaching of poetry.

Dead Poets Society
Dead Poets Society (1989)

The film was a commercial success and received numerous accolades, including Academy Award5 nominations for Best Director, Best Picture, and Best Actor for Robin Williams. The film won the BAFTA Award for Best Film6, the César Award for Best Foreign Film7 and the David di Donatello Award for Best Foreign Film8. Schulman received an Academy Award for Best Original Screenplay9 for his work.

Assignment

A registry is a text file in which each line describes a person using a fixed number of information fields. Fields are numbered from left to right starting at zero, separated by commas (,) and do not contain commas themselves. The first field always contains the name of the persons, with all persons in the file having unique names. As an example, these are some lines from a registry with information about poets (poets.txt10): their name (field 0), date of birth (field 1) and date of death (field 2).

Thomas Chatterton,1752-11-20,1770-08-24
Phillis Wheatley,,1784-12-05
Percy Bysshe Shelley,1792-08-04,1822-07-08
John Keats,1795-10-31,1821-02-23
Emily Brontë,1818-07-30,1848-12-19
Walt Whitman,1819-05-31,
Rupert Brooke,1887-08-03,1915-04-23
Guillaume Apollinaire,1880-08-26,1918-11-09
Wilfred Owen,1893-03-18,1918-11-04
Keith Douglas,1920-01-24,1944-06-09
Sylvia Plath,1932-10-27,1963-02-11

A date field in a registry contains a date in the format YYYY-MM-DD. The corresponding date field remains empty if no date is known for a specific person.

Note

A registry uses the UTF-811 character encoding. When processing such text files, it is recommended to explicitly specify the encoding: encoding='utf-8'.

Your task:

Example

In the following interactive session we assume the text file poets.txt12 is located in the current directory.

>>> born = read_dates('poets.txt13', 1)
>>> born['Emily Brontë']
datetime.date(1818, 7, 30)
>>> born['Walt Whitman']
datetime.date(1819, 5, 31)
>>> born['Phillis Wheatley']
Traceback (most recent call last):
KeyError: 'Phillis Wheatley'

>>> died = read_dates('poets.txt14', 2)
>>> died['Emily Brontë']
datetime.date(1848, 12, 19)
>>> died['Walt Whitman']
Traceback (most recent call last):
KeyError: 'Walt Whitman'
>>> died['Phillis Wheatley']
datetime.date(1784, 12, 5)

>>> lifespan('Emily Brontë', born, died)
[1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848]
>>> lifespan('Walt Whitman', born, died)
Traceback (most recent call last):
AssertionError: missing information
>>> lifespan('Phillis Wheatley', born, died)
Traceback (most recent call last):
AssertionError: missing information

>>> poets = alive(born, died)
>>> poets[1798]
{'John Keats', 'Percy Bysshe Shelley'}
>>> poets[1895]
{'Guillaume Apollinaire', 'Rupert Brooke', 'Wilfred Owen'}
>>> poets[1952]
{'Sylvia Plath'}

>>> wonder_years(poets)
{1818, 1819, 1820, 1821, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915}

>>> summarized({2001, 2002, 2003, 2004, 2012, 2015, 2018, 2019, 2020, 2022})
'2001-2004, 2012, 2015, 2018-2020, 2022'
>>> summarized(lifespan('Emily Brontë', born, died))
'1818-1848'
>>> summarized(wonder_years(poets))
'1818-1821, 1893-1915'

Epilogue

One of the functions in this assignment is a reference to The Wonder Years15, a coming-of-age television series that ran on the American broadcast network ABC16 from January 31, 1988, until May 12, 1993.

The Wonder Years (1988-1993)
Paul, Kevin en Winnie

The series depicts the social and historical events of the late 1960s and early 1970s as seen through the eyes of 12-year-old Kevin Arnold. In addition to the usual pubertal ailments, he took care of all kinds of teenage social matters. His best friend Paul and the girl next door, Winnie Cooper, were his steady companions. Each episode is narrated by a now grown-up Kevin Arnold who looks back on his childhood years and shares his deepest soul stirrings of his "wonder years" with the viewer. The theme song was Joe Cocker17s' cover of The Beatles18' With a Little Help from My Friends19.