Home > Software design >  Is it possible to add an empty dictionary to a python class?
Is it possible to add an empty dictionary to a python class?

Time:12-13

Is it possible to add an empty dictionary with self parameters into a class so that I can add elements to it later with a defined method?

CodePudding user response:

To add an empty dictionary is just like adding any other variable:

class SomeClass:
    def __init__(self):
        self.empty_dict = {}
  • Related