inshu chauhan <insidesh...@gmail.com> wrote: > This statement is giving me the following error > > Statement: > for p, k, j in zip(sorted(segments.iterkeys(), class_count.iterkeys(), > pixel_count.iterkeys())): > > Error: > Traceback (most recent call last): > File "C:\Users\inshu\Desktop\Training_segs_trial2.py", line 170, in ><module> > access_segments(segimage, data) > File "C:\Users\inshu\Desktop\Training_segs_trial2.py", line 147, in > access_segments > for p, k, j in zip(sorted(segments.iterkeys(), > class_count.iterkeys(), > pixel_count.iterkeys())): > TypeError: 'dictionary-keyiterator' object is not callable >
The second argument to `sorted()` is a comparison or key function, if you want to sort all three key lists you need to sort them separately. Try: for p, k, j in zip(sorted(segments), sorted(class_count), sorted(pixel_count)): also you don't need to call the `iterkeys()` method as you need them all to sort and just treating the dict as a sequence will do the right thing. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list