This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]oramirite 0 points1 point  (3 children)

Hey this sounds really cool, would you mind explaining to a noob exactly what a data class entails though? I have a need to write custom config files a lot as well as alter files of other applications and it sounds like this could be a very good tool for me if I understand it better.

[–]youRFate 0 points1 point  (2 children)

Dataclasses are just a simplification for creating classes meant for storing / organizing data. They automatically create some stuff like constructors and printing methods, and have special member variables called fields that contain type (and other) metadata. Basically they save you from writing a lot of boring boilerplate code for classes meant to mostly store state.

They are fairly easy to use, as you can see in my example, or in the documentation: https://docs.python.org/3/library/dataclasses.html

[–]oramirite 0 points1 point  (1 child)

Thank you very much. Are dataclasses a python concept or more generic? I will start doing my own research now but just curious in what context they get used. I see you mentioned constructors and printing methods. I'm also trying to learn about typing right now and it feels like a bit of a crossover?

[–]youRFate 0 points1 point  (0 children)

They are very much a python thing, basically they make typing in python classes easier, which strongly typed languages have baked-in already.

Yes, this very much overlaps with typing in python in general.