I was working on a project when this situation occurred. I've defined a base class that initialises a dict and then I've the derived class that adds something more to the dict.
Now when I run the program, I end up getting a keyerror.
Here's the code I've used.
Now when I run the program, I end up getting a keyerror.
Here's the code I've used.
class Base: context = {} def __init__(self): context = { 'style': [ 'apple', 'balls' ], 'script': [ 'cat', 'dog' ] } class Derived(Base): def __init__(self): self.context['style'].append('Kite') obj = Derived() print(obj.context)I guess I've something silly.