Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

Timeline for answer to C-like structures in Python by dF

Current License: CC BY-SA 2.5

Post Revisions

8 events
when toggle format what by license comment
Feb 17, 2021 at 10:29 comment added ilkkachu ...especially since you can just do a = dict(foo=123, bar=456) to make that dict if you like the function call syntax with keywords better than the regular dict syntax, and also str()/repr() are somewhat more useful than just giving the object id.
Dec 5, 2020 at 22:14 comment added Basj This uses an object, with, internally, a dict __dict__ (well, like all objects, except if you use __slots__). So why not use a dict directly? mystruct = {'field1': value1, 'field2': value2}. TL;DR: here you're creating an object just for the purpose of using its internal dict object.__dict__, so it would be less complex to simply use a dict from the beginning.
May 23, 2015 at 5:15 comment added Evgeni Sergeev @KurtLiu No, it would probably say TypeError: this constructor takes no arguments
Oct 30, 2011 at 18:28 comment added LeBleu Note if you are new to python: tuples are read-only once created, unlike C structs
Jul 20, 2011 at 18:01 comment added Kurt Liu Would a empty class just do the same?
Sep 6, 2010 at 2:24 history edited jfs CC BY-SA 2.5
fixed broken link
Aug 30, 2008 at 22:08 history edited dF. CC BY-SA 2.5
added 239 characters in body
Aug 30, 2008 at 14:38 history answered dF. CC BY-SA 2.5