[Zope] Sorting objectValues in Python Script

Tim Hoffman timhoffman@cams.wa.gov.au
18 Oct 2002 16:29:33 +0800


On Fri, 2002-10-18 at 16:24, Jerome Alet wrote:
> On Fri, Oct 18, 2002 at 10:20:27AM +0200, Jerome Alet wrote:
> > On Fri, Oct 18, 2002 at 10:15:10AM +0200, Andreas Tille wrote:
> > > Hello,
> > > 
> > > I just want to build a sorted list of
> > > 
> > >    list = context.objectValues('ExtFile')
> > >    for file in list:
> > >         print file.id, file.title
> > >    return printed
> > 
> > <UNTESTED>
> > list.sort(lambda x,y : cmp(y.getId(), x.getId()))
> > </UNTESTED>
> 
> Sorry I think this won't work in a Python Script because IIRC
> lambda is forbidden there.

Sorry not true lambda isn't forbidden in Scripts.

I use lambda in sorts in PythonScripts all the time.

Rgds

Tim



> 
> Replace the lambda with a normal function and it should be ok.
> 
> Jerome Alet
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )