Keith Devens .com |
Monday, December 1, 2008 | ![]() |
| Less isn't more; just enough is more. – Milton Glaser | ||
|
| ← Shouldn't you lose your job when you do something like this? | The Taoist Parable About Luck → |

Ian Bicking (http://blog.ianbicking.org) wrote:
Harry Fuecks (http://www.phppatterns.com) wrote:
Agreed. Would also be good to do the reverse. The new SPL extension http://www.php.net/spl allows you to define classes which implement special iterator interfaces. Once done you can iterate of objects of the class using foreach. Unfortunatly nothing else, array-wise, seems to work (such as using array_map() - would be nice if the interface defined something to allow that)
Keith (http://keithdevens.com/) wrote:
Python also has classes like UserDict.DictMixin...
Ah! I was thinking that there should be something exactly like that! Thanks for the info.
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):
Generated in about 0.206s.
(Used 8 db queries)

Python also has classes like UserDict.DictMixin which will allow you to implement a small number of methods, and all the other methods are filled in for you. All you have to set is methods for getting, setting, deleting, and listing all keys.