I am testing the existence of local variables LatLim and LongLim at the Spyder console: >>> LatLim = (36.033333,36.2333) >>> LongLim = (-5.5333,-5.25) >>> locals().keys() dict_keys(['__name__', '__builtin__', ... 'LatLim', 'LongLim', ... ]) Each variable tests fine by itself: >>> 'LatLim' in locals().keys() True >>> 'LongLim' in locals().keys() True The OR'ing of the test should be True but is False: >>> any( key in locals().keys() for key in ('LatLim','LongLim') ) False If I create a dictionary of local keys, the test succeeds: >>> LocalsKeys = locals().keys() >>> any( key in LocalsKeys for key in ('LatLim','LongLim') ) True Why does the OR'ing fail when checking locals().keys() directly? Continue reading...