on-internet
← Community

Set the configuration file using dataclass such that some variables can be mutable and some variables are immutable

Stack Overflow ·

I would like to write a configuration file for the AWS services e.g.: BucketName, job name, etc such that the file is configurable by the user if required. These are some of the works I have carried using the dataclasses. Setting the frozen=True to dataclass, all the variables are immutable. from dataclasses import dataclass @dataclass(frozen=True) class AWSConfiguration: bucket = {"bucket_name": "s3:///abc/"} jobqueue = {"job_def_name": "aws_service"} writing a value to variable of the class: AWSConfiguration().jobqueue = "a" It throws the following error: FrozenInstanceError: cannot assign t

Comments

Sign in or sign up to comment and upvote.

No comments yet.