Python dataclasses

Hi all,

Been working with dataclasses in python and hoping to start a discussion for those who are using them.

If anyone has any tips or tricks post them below.

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

Here is an example I am looking for assistance with something like this:

from dataclasses import dataclass @dataclass class Student: name: str subject: str year: int grade: str mike = Student("Mike", "Math", 11, "A") print(mike)

If I am looking to use this, is it possible to use this class where you can change the year to update the grade, but not lose the prior year’s data?