Storage.__class__ = dict tricks isinstance

This commit is contained in:
mdipierro
2012-08-20 12:04:55 -05:00
parent 6673743406
commit 7898e4aac3
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-08-20 11:57:27) dev Version 2.00.0 (2012-08-20 12:04:52) dev
+3 -1
View File
@@ -51,7 +51,7 @@ class List(list):
return value return value
class Storage(object): class Storage(object):
__class__ = dict
""" """
A Storage object is like a dictionary except `obj.foo` can be used A Storage object is like a dictionary except `obj.foo` can be used
in addition to `obj['foo']`, and setting obj.foo = None deletes item foo. in addition to `obj['foo']`, and setting obj.foo = None deletes item foo.
@@ -100,6 +100,8 @@ class Storage(object):
return self.__dict__.values() return self.__dict__.values()
def items(self): def items(self):
return self.__dict__.items() return self.__dict__.items()
def len(self):
return len(self.__dict__)
def __iter__(self): def __iter__(self):
return self.__dict__.__iter__() return self.__dict__.__iter__()
def has_key(self,key): def has_key(self,key):