On Mon, Jan 26, 2015 at 8:50 AM, Adam Funk <a24...@ducksburg.com> wrote: > On 2015-01-26, Peter Otten wrote: > >> Adam Funk wrote: >> >>> On 2015-01-09, Ned Batchelder wrote: >>>> for b in options.bar or (): >>>> do_stuff(b) >>> >>> Do you mean "for b in options.bar or []:" ? >> >> Doesn't matter; in the context of a for loop any empty iterable would do. > > Of course it would. Doh!
Stylistically, I generally prefer the empty list for this. The empty tuple might be a little faster since it's a singleton and doesn't need to be constructed at runtime, but that's clearly a micro-optimization, and I think the list more accurately conveys the intention of "something to be iterated over". Although tuples are iterable, I don't often use them for that purpose. -- https://mail.python.org/mailman/listinfo/python-list