On Tuesday 28 November 2006 06:12, OKB (not okblacke) wrote: > Carsten Haese wrote: > > You can change the behavior of a list's sort method by overriding > > sort. You can't change the behavior of sort by overriding > > __getitem__ and __setitem__, because sort does not call __getitem__ > > or __setitem__. > > Why doesn't it?
I also expected that it did! I perfectly understand that this adds significant penalty to the execution of code. But in the way things are, I have to know ( or guess ?) how its function has been implemented. And I cannot handle all cases the same. If I provided my sort method for my class in Python, wouldn't this call my __getitem__ and __setitem__ methods (considering l[i] = j assignment do)? Can this be considered an in consitency? -- Michalis Giannakidis -- http://mail.python.org/mailman/listinfo/python-list