I’ve been using python for a while and I’ve never run into this.
I am passing a dict to a class and assigning it to a class variable like so.
class Validator(ABC):
def __init__(self, available_messages, rule_list: dict, data) -> None:
self.available_messages = available_messages,
self.rule_list: dict = rule_list,
self.data = data
self.messages = []
self.validate()
If I print the type of rule_list prior to assigning it to self.rule_list I get <class 'dict'>. Immedietly after assignment, I get <class 'tuple'>.
I want to keep rule_list as a dictionary. What am I doing wrong?
Thanks
Advertisement
Answer
The problem is the comma at the end of the Line, making it a tuple