Add autodict class

master
Sven Slootweg 13 years ago
parent d47f592d60
commit 9195ffc6af

@ -21,6 +21,15 @@ def split_irc(message):
else: else:
return message.split(" ") return message.split(" ")
class autodict(dict):
# http://stackoverflow.com/a/652284
def __getitem__(self, item):
try:
return dict.__getitem__(self, item)
except KeyError:
value = self[item] = type(self)()
return value
class ircd: class ircd:
channels = {} channels = {}
users = {} users = {}

Loading…
Cancel
Save