n00b question: Better Syntax for Coroutines?

2008-09-12 Thread ig
First off, I'm a python n00b, so feel free to comment on anything if
I'm doing it "the wrong way." I'm building a discrete event simulation
tool. I wanted to use coroutines. However, I want to know if there's
any way to hide a yield statement.

I have a class that I'd like to look like this:

class Pinger(Actor):
def go(self):
success = True
while success:
result = self.ping("128.111.41.38")
if result != "success":
success = False
print "Pinger done"

But because I can't hide yield inside ping, and because I can't find a
convenient way to get a self reference to the coroutine (which is used
by the event queue to pass back results), my code looks like this:

class Pinger(Actor):
def go(self):
# I dislike this next line
self.this_pointer = (yield None)
success = True
while success:
# I want to get rid of the yield in the next line
result = (yield self.ping("128.111.41.38"))
if result != "success":
success = False
print "Pinger done"

I posted a more detailed version of this as a rant here:
http://illusorygoals.com/post/49926627/

I'd like to know, is there a way to get the syntax I want? After
staying up late last night to get a proof-of-concept working with
coroutines, my boss expressed disappointment in the ugliness of the
Pinger code (we agreed on the desired syntax above). I spent almost 2
hours today to migrate the system over to threads. That made my boss
happy, but I'm still curious if I can do something to salvage the
coroutine version.

Regards,
IG
--
http://mail.python.org/mailman/listinfo/python-list


soap comlex data to plain xml

2006-08-18 Thread Ig B
Hi all,would anyone give me a hint how to get SOAP data as plain XML and not as complex datathis is sample code:  myProxy = SOAPpy.SOAPProxy(MY_SERVICE_PATH, header = my_headers)  query = SOAPpy.structType

()  result = myProxy.callMyProcedure(query)  result returned as complex data, but i need plain xml text - kind of you see when myProxy.config.dumpSOAPIn = 1thank you in advance.~GB
-- 
http://mail.python.org/mailman/listinfo/python-list