Return a string result with out breaking loop

Benjamin Kaplan benjamin.kaplan at case.edu
Mon Aug 25 20:47:49 EDT 2008


On Mon, Aug 25, 2008 at 8:19 PM, Andrew <nobody at yahoo.com> wrote:

> Hi Ive been trying with yield all day and other different things :D
>
> but I always get the same result using yield
>
> Fault: <Fault 1: "<type 'exceptions.TypeError'>:cannot marshal <type
> 'generator'
> > objects">
>
> I'm not sure exactly what I am doing wrong as this is the first time Ive
> used yield
>
> Any suggestions on how to fix this error
>
> Cheers
>
> Andrew
>


Do you know how to use generators? What you are trying to do is probably

foo(somefunc())

what you actually want is probably closer to

gen = somefunc()
for item in gen :
    foo(item)

***This is just an assumption based on your error message. Without seeing
more of your code, I don't know exactly what is causing your error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080825/9b63bae4/attachment-0001.html>


More information about the Python-list mailing list