Super excited to release the latest version of "A Data-Centric Introduction to Computing" (DCIC). See release notes for 2025-08-27 for what's changed and new (a LOT!): dcic-world.org/2025-08-27/R.... dcic-world.org
Super excited to release the latest version of "A Data-Centric Introduction to Computing" (DCIC). See release notes for 2025-08-27 for what's changed and new (a LOT!): dcic-world.org/2025-08-27/R.... dcic-world.org
In the "from pyret to python" track, "data classes" are introduced as the counterpart for pyret's "data". Were NamedTuples (`from typing`) not considered for that stage (since they're also immutable) to avoid proliferating concepts? NTs might be a better fit there and dataclasses for mutables right?
Great question. I'm going to refer this to the people most responsible for that. Personally, I've always *thought* of data classes as the right analog, since they are a lightweight form of defining structures. But Python keeps adding features and this is one I missed!
When I wrote the first version of the materials that became the early part of DCIC, multiple people who used Python in practice more than I did recommended data classes. I seem to recall trying NamedTuples a couple of years later. >>
I vaguely recall having problems with `typing` at the time (2019ish), and I didn't want to force it on the students. I also like dataclasses because they provide a lightweight use of the class concept. I was setting that up for my students because they were going from DCIC into a course on OO. >>
I'd have to think a bit more about other differences (when the start of the semester isn't upon me). I do see why NamedTuples could feel more in line with the DCIC style, but I also see the challenges that students have jumping into full classes after the syntactic brevity of Pyret and Python.
That's understandable. The early incarnations of NT have been kinda yuck to force on students. However the recent versions have solidified NamedTuple to not even require explaining decorators. It read a tad awkward in the text having to explain why the dataclass didn't change form to get mutability.
typing.python.org/en/latest/sp... - to add to the confusion, googling for "python namedtuple" still takes students to the older form in the "collections" module. So I was wondering what went into the choice.