> Sorry! > > X = stepper() > X.data = "Spam" Aha! The fog in my brain clears.
>> > >>> class stepper: >> >... def __getitem__(self, i): >> >... return self.data[i] >> >... >> > >>> 'p' in X >> >True >> > >> >What does 'in' have to do with indexing? To find out if 'p' is in X Python has to step through the data in X. I'm not sure that your getitem is being called, it may just be a string search operation. But I suspect it may assume the data is an iterator and repeatedly call next() till it gets a match or runs out of data. In that case getitem may well get called. a simple print statement in getitem will find out... Alan G. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor