From 731390e40a180c4872b31f950bb30b6f75bb426e Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sat, 29 Oct 2011 18:15:06 -1000 Subject: [PATCH] make MCMaterials an iterable over its own blocks --- materials.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/materials.py b/materials.py index 3b6344b..71b55f2 100644 --- a/materials.py +++ b/materials.py @@ -105,7 +105,13 @@ class MCMaterials(object): return self[key] except KeyError: return default - + + def __len__(self): + return len(self.allBlocks) + + def __iter__(self): + return iter(self.allBlocks) + def __getitem__(self, key): """ Let's be magic. If we get a string, return the first block whose name matches exactly. If we get a (id, data) pair or an id, return