looping list problem

Jon Bowlas me at jonbowlas.com
Tue Aug 16 15:24:55 CEST 2005


Ok so I changed it to this: 

attobject = context.get_attobject()
navstring = context.get_uclattribute(attobject, 'ucl_navhide')
hiddennavelements = navstring.split(' ')
for hiddennavelement in hiddennavelements:
    yield hiddennavelements

But I get the following error- Line 5: Yield statements are not allowed.

Any ideas

-----Original Message-----
From: python-list-bounces+me=jonbowlas.com at python.org
[mailto:python-list-bounces+me=jonbowlas.com at python.org] On Behalf Of
Fredrik Lundh
Sent: 16 August 2005 13:44
To: python-list at python.org
Subject: Re: looping list problem

Jon Bowlas wrote:

> attobject = context.get_attobject()
> navstring = context.get_uclattribute(attobject, 'ucl_navhide')
> hiddennavelements = navstring.split(' ')
> for hiddennavelement in hiddennavelements:
>    return hiddennavelement
>
> So the script 'get_attobject' basically looks for an instance of the
> attributes object in the current folder, if it doesn't locate one then it
> uses acquisition to find one in a parent folder. The script
> 'get_uclattribute' then gets the nodeValues of the requested node. In this
> instance its ucl_navhide, then I split the 'navstring' string at the
spaces
> and attempt the for-loop to output each of the values.
>
> Unfortunately it appears I am unable to loop through each of the list
items
> in hiddennavelements, as it only returns the first value & will not
repeat.

did you perhaps mean to use "yield" instead of "return" ?

</F> 



-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list