[Zope] Help: simple python method goes wrong

Max M maxm@mxm.dk
Wed, 05 Jun 2002 11:12:47 +0200


Julian Knight wrote:

>I have a Python method as follows:
>
>
>results=[]
>for object in context.objectValues('DTML Document'):
>  results=results.append(object)
>return results
>

wouldn't that be:

results=[]
for object in context.objectValues('DTML Document'):
    results.append(object)
return results

or:

results=[]
for object in context.objectValues('DTML Document'):
    results += [object]
return results

or even with list comprehensions:

return [object for object in context.objectValues('DTML Document')]


regards Max M