iterables

I don't like Python functions that take two or more iterables. Is it a good idea?

This question came from looking at this question on Stackoverflow. def fringe8((px, py), (x1, y1, x2, y2)): Personally, it's been one of my pet peeves to see a function that takes two arguments with fixed-number iterables (like a tuple) or two or more dictionaries (Like in the Shotgun API). It's just hard to use, because of all the ve...

idiomatic way of taking action on attempt to loop over an empty iterable

Suppose that I am looping over a iterable and would like to take some action if the iterator is empty. The two best ways that I can think of to do this are for i in iterable: # do_something if not iterable: # do_something_else and empty = True for i in iterable: empty = False # do_something if empty: # do_someth...