When you create a generator object in python like this:
def gen():
print("Hello")
yield 1
x=gen()
print(x)
the only console output will be: < generator object gen at xxx>. Why does it not print "Hello" as well? If you change the gen function to just return a value instead of a generator (so change out "yield" with "return"), the print command is executed so that the console output is:
Hello
< generator object gen at xxx>
Why does that happen? How can I execute commands inside of generator functions?