python generator have driven me crazy