M
marduk
I have a weird request.
I want to be able to say
def myvalues():
while True:
# stuff that determines a new somevalue
yield somevalue
x = "Hello, %s, this is a %s with %s and %s on top of %s" % myvalues()
y = "Yes it's true that %s has way too many %s's" % myvalues()
I was hoping that myvalues() would be iterated over, but instead the
interpreter gives me a "TypeError: not enough arguments for format string"
error. I tried tuple(myvalues()) and I think that kinda works but of
course myvalues goes into an infinite loop. myvalues will not know before
hand how many times it will be called.
Is there actually a simple way of doing this that I'm overlooking?
I want to be able to say
def myvalues():
while True:
# stuff that determines a new somevalue
yield somevalue
x = "Hello, %s, this is a %s with %s and %s on top of %s" % myvalues()
y = "Yes it's true that %s has way too many %s's" % myvalues()
I was hoping that myvalues() would be iterated over, but instead the
interpreter gives me a "TypeError: not enough arguments for format string"
error. I tried tuple(myvalues()) and I think that kinda works but of
course myvalues goes into an infinite loop. myvalues will not know before
hand how many times it will be called.
Is there actually a simple way of doing this that I'm overlooking?