On Thu, Feb 19, 2009 at 07:52:43PM -0800, johan...@sun.com wrote: > The problem is that this code doesn't treat the thing it calls a list as > an iterable. It calls list(fmri_list) on the object and then proceeds > to treat it as a list. You don't call list() on an actual list;
Well, you can, and it would have exactly the same behavior, but I see your point -- it expects a generator, or otherwise it wouldn't need to cache the contents so that it can re-iterate. Does it ever take anything but a generator, or other unsized iterator? If it weren't for the progress tracking, the loop could be written as for idx, elem in enumerate(fmri_list): if stopping_early: break added_fmri = elem ... and you could catch a TypeError when calling len(fmri_list) in the progress tracker start, allowing for a sized iterator to give you percentage progress, and an unsized iterator such as a generator to simply give you a spinner. Or, if you know the length of the generator, you could pass that in, too. At any rate, from the point of view of the consumer of the method, you can pass in any iterable you want, and that's who would care about the name of the argument. So I'd probably just call it "fmris", and the method _process_fmris(). The method itself can handle its input however is most appropriate. But given how deep in the guts this thing is, I don't really care too much. Regardless, it'd be good to update the docstring to remove the specific mention of "list". Danek _______________________________________________ pkg-discuss mailing list pkg-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/pkg-discuss