This idea elif x == funky_empty: result = 'no data' Can be accomplished with if not len(items): result = 'no data' which means that part of the proposal can be scratched IMHO.