Skip to main content

Timeline for answer to What are "named tuples" in Python? by fmark

Current License: CC BY-SA 3.0

Post Revisions

14 events
when toggle format what by license comment
Oct 10, 2023 at 4:38 comment added InSync I know this is not what the question is about, but for calculating Euclidean distances, there's math.hypot(): line_length = math.hypot(pt2.y - pt1.y, pt2.x - pt1.x).
Nov 15, 2022 at 4:10 comment added schimmy Folks looking at this functionality might also be interested in Data Classes (peps.python.org/pep-0557) which are described as 'mutable namedtuples with defaults'. You can think of them as in-between namedtuples and a full class. Essentially, if you want lightweight objects that have nice properties like equality operators and default fields, Data Classes might be the right choice.
Sep 14, 2022 at 14:36 comment added Klaus The usage in Python versions >= 3.6 could be added. This usage is stated in the implementation: Usage in Python versions >= 3.6:: class Employee(NamedTuple): name: str id: int This is equivalent to:: Employee = collections.namedtuple('Employee', ['name', 'id'])
S May 31, 2017 at 3:58 history suggested cade CC BY-SA 3.0
Added needed hyphens to improve readability and removed duplicate 'For example' phrase.
May 30, 2017 at 22:19 review Suggested edits
S May 31, 2017 at 3:58
Mar 21, 2014 at 16:58 review Suggested edits
Mar 21, 2014 at 17:00
Jun 16, 2010 at 6:26 history edited fmark CC BY-SA 2.5
added 4 characters in body
Jun 5, 2010 at 16:13 vote accept Denilson Sá Maia
Jun 5, 2010 at 1:34 history edited fmark CC BY-SA 2.5
added import
Jun 4, 2010 at 5:54 history edited fmark CC BY-SA 2.5
Added recordtype example
Jun 4, 2010 at 1:15 history edited fmark CC BY-SA 2.5
Added more info on mutability
Jun 4, 2010 at 1:06 history edited fmark CC BY-SA 2.5
added reference to struct types
Jun 4, 2010 at 0:29 history edited fmark CC BY-SA 2.5
added 293 characters in body
Jun 4, 2010 at 0:19 history answered fmark CC BY-SA 2.5