class Karl: "some class for testing concepts and syntax" a = [] def __setitem__(self, a, aa): a = aa print " ".join(["setitem", str(a), "=", str(aa)]) def __getitem__(self, a): print " ".join(["getitem", str(a)]) return a interaction: >>> import test3 >>> hej = test3.Karl() >>> hej[""] getitem '' >>> hej[""] = [1,2] setitem [1, 2] = [1, 2] >>> hej[""] getitem ''