python 3 self class dict

Posted by Jjang on Stack Overflow See other posts from Stack Overflow or by Jjang
Published on 2012-06-15T21:13:37Z Indexed on 2012/06/15 21:16 UTC
Read the original article Hit count: 107

Filed under:
|
|

I am trying to create my own class of dictionary in python 3 which has a field of dict variable and setitem and getitem methods. Though, it doesnt work for some reason. Tried to look around but couldn't find the answer.

class myDictionary:
    def __init(self):
        self.myDic={}

    def __setitem__(self, key, value):
        self.myDic[key]=value

I'm getting:

'myDictionary' object has no attribute 'myDic'

Any ideas? :)

© Stack Overflow or respective owner

Related posts about python

Related posts about methods