[Zope-dev] Returning a list of names from a Python Method
Michael Bernstein
webmaven@lvcm.com
Mon, 18 Sep 2000 18:06:39 -0700
Bill Anderson wrote:
>
> Michael Bernstein wrote:
> >
> > I *think* I've created a getUserNames python method that returns the
> > appropriate results:
> >
> > Parameter list:
> > self
> >
> > Body:
> >
> > user_ids=self.UserSource.getPersistentItemIDs()
> >
> > names=[]
> > for i in user_ids:
> > names.append(self.getItem(i))
> > return names
>
> Returns a list of objects.
>
> > I don't understand the differences between the code I pasted above and
> > the code on the original getUserNames method (from :
> >
> > def getUserNames(self):
> > """Return a list of usernames"""
> > names=self.data.keys()
> > names.sort()
> > return names
>
> Returns a list of usernames.
>
> > Can anyone tell me what I need to fix?
>
> Unfortunately, I cannot yet.
Does anyone on the list know how to change the getUserNames
Python method to return a list of names instead of a list of
objects?
The code in question is this:
user_ids=self.UserSource.getPersistentItemIDs()
names=[]
for i in user_ids:
names.append(self.getItem(i))
return names
Thanks,
Michael Bernstein