[Zope] Help using list within python method
Paul Winkler
pw_lists@slinkp.com
Fri, 21 Mar 2003 16:02:46 -0500
On Fri, Mar 21, 2003 at 03:48:45PM -0500, Michael Long wrote:
> 172 def listEntriesByGroup(self, groups=["All"]):
> 173 "Method to list Entries"
> 174 ret=[]
> 175 if type(groups) != ListType:
> 176 EntryIDs = [groups]
you don't use EntryIDs again... maybe you mean:
groups=[groups]
> 177 if groups == "All":
> 178 for entry in self.Entries.values():
> 179 ret.append(entry)
> 180 else:
> 181 for entry in self.Entries.values():
> 182 if entry.Group in groups:
(snip)
> Module Products.dlAddressBook.AddressBook, line 182, in listEntriesByGroup
> TypeError: 'in <string>' requires character as left operand
yep, you passed in groups="some string" and didn't convert it to a list
before looping over it.
--
Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's PUMA NAZI!
(random hero from isometric.spaceninja.com)