Eric S. Johansson schrieb: > I apologize if this is an FAQ but googling has not turned up anything, > at least to my keywords. > > I need to parse a configuration file from an existing application and > I'm treating it as a dictionary. I created my class with a parent class > of dict. Everything works okay except I discover I need to force keys > to uppercase when setting a value. > > I override __setitems__ and, as you'd expect, I get a recursive loop. > I'm obviously missing a clue on how to break the recursion. My > admittedly simpleminded method overloading looks like: > > def __setitem__ (self, index, value): > """force keys to uppercase""" > self[index.upper()] = value dict.__setitem__(self, index.upper()) = value
Or better even super(subclass, self).__setitem__(key.upper(), value) DIez -- http://mail.python.org/mailman/listinfo/python-list