No, it has nothing to do with the pathname. Try this: def f(nested): if not nested: f(True) else: yield 42 for k in f(False): print k Step through it in the mind: - f(False) gets called - it is not nested, so f(True) gets called - it is nested, so should yield 42 - but it doesn't! - instead, you get an empty list.