Skip to main content

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

Current License: CC BY-SA 3.0

Post Revisions

7 events
when toggle format what by license comment
Dec 25, 2022 at 18:14 comment added Mike 'Pomax' Kamermans This'd be nicer as a class decorator though, allowing for something like @as_struct \n class MyStruct: \n a = somedefault \n b = somedefault where the decorator builds the real class based on the static varnames, with default assignment if the class is instantiated with one (or more) members missing. Having to decorate a function inside the class, and needing a pass ends up basically being the same amount of code as a normal class.
Mar 28, 2016 at 19:31 comment added wombatonfire +1 for mentioning func_code. Started digging in that direction and found lots of interesting stuff there.
Sep 8, 2015 at 2:39 comment added ArtOfWarfare Damnit - I spent two hours today writing up my own decorator to do this and then I found this. Anyways, posting mine because it handles default values while yours doesn't. stackoverflow.com/a/32448434/901641
Mar 26, 2015 at 10:29 history edited user124757 CC BY-SA 3.0
fixed the code so it actually assigns to instance variables, added the decorator version posted on reddit
Mar 26, 2015 at 10:24 history edited user124757 CC BY-SA 3.0
fixed the code so it actually assigns to instance variables
Mar 23, 2015 at 16:15 history edited user124757 CC BY-SA 3.0
added more info and change meta-programming to meta-classes, feels more accurate
Mar 23, 2015 at 14:32 history answered user124757 CC BY-SA 3.0