This is a rather strange question, so I will explain:
I have a generator like this that acts as a generator interface for an IRC server:
def irc_iter():
msgs = get_msgs()
for msg in msgs:
if is_ping(msg):
pong()
else:
to_send = yield msg
for s in to_send:
send(s)
This, theoretically, should allow me to do something cool, for example:
server = connect()
for line in server:
if should_respond(line):
server.send('WOW SUCH MESSAGE')
However, there is a hitch: generator.sendalso gives the following meaning. This means that it server.sendalso gives me the following message ... which I would prefer to process like all other messages received as line.
I know that I can fix this ugly by simply yielding the value of spam after receiving the send, but I try to make my code elegant, and vice versa. Is there any way to tell the generator that I do not want a new value?
Thank.