Skip to content

Instantly share code, notes, and snippets.

@quiye
Last active February 26, 2018 13:48
Show Gist options
  • Save quiye/06836654fd133239898d055ca895c8de to your computer and use it in GitHub Desktop.
Save quiye/06836654fd133239898d055ca895c8de to your computer and use it in GitHub Desktop.
OrderedDictの継承
# -*- coding: utf-8 -*-
num=0
from collections import OrderedDict
class TestExtends(OrderedDict):
def __init__(self):
OrderedDict.__init__(self)
def append(self,key,value):
global num
self[key]=value
self[num]=num+1
num+=1
print("値が追加されました:" + str(key)+str(value))
if __name__ == "__main__":
test = TestExtends()
test.append("python",3)
test.append("-",'mmm')
test.append(1,'mmm')
test.append(22222222222,"izm")
test['hoge']=99
test['hoge2']=99
print "==============="
print test.keys()
print test.values()
print test.items()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment