Skip to content

Instantly share code, notes, and snippets.

@rajmayank
Created June 10, 2021 01:57
Show Gist options
  • Save rajmayank/f2af6d0994589f0e646960074c194e95 to your computer and use it in GitHub Desktop.
Save rajmayank/f2af6d0994589f0e646960074c194e95 to your computer and use it in GitHub Desktop.
Python-Generators-Anitopatterns
theGlobalMultiplier = 5
def myMultiplyingGenerator(numbers):
for number in numbers:
yield number * theGlobalMultiplier
for multipliedNumber in myMultiplyingGenerator(range(1,10)):
if multipliedNumber > 25:
theGlobalMultiplier = 10
print(multipliedNumber)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment