Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2510
| From | sl33k <ahsanbagwan@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Problem regarding returning list |
| Date | 2011-04-03 00:17 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <ed6915b6-921c-46e9-bb14-a889ee0bf626@i35g2000prd.googlegroups.com> (permalink) |
| References | <89e48525-0bcc-4cc3-9f44-c3d86be3313c@34g2000pru.googlegroups.com> |
On Apr 3, 3:12 am, sl33k <ahsanbag...@gmail.com> wrote: > I am trying to return a list of items modified with each item also > showing like the number of modifications. > > Returning a list of user modified items was done easily but I would > also like to display the item modified by the user and the > modifications of that particular item. > Typical way it coould be displayed like is, > Modified item: No of modifications to it > > E.g. sl33k: 3 > > Some background of the base class methods used: > > list_revisions() - gets the list of ints of the all modification of a > particular item > get_revision() - given the modification int, it gets the specific > modified item. > item.name gives the name of the item > The method takes for argument the list of items. > > I start by declaring a set() of the total modified items. Using for > loop in the items and in the for loop for particular `int` > modification of it, I collect the modified item. > But, I get stuck around when I have to collect the no of modifications > for one. The set is returned as a list to a template engine for the > display. > > So, I would like to collect for each item, its no of modifications. > How would I go about doing this? How would i return it with list of > modified items tp display the above shown example? > > Any pointers will be much appreciated. > > Code: > > def foo(items): > > modified_items = set() > rev_count = [] > for item in items: > item_name = item.name > revnos = item.list_revisions() > for revno in revnos: > revision = item.get_revision(revno) > if modications userid == loggedin users userid: > contribution_items.add(item_name) > > # How do i collect revisions here > > return list(contribution_items) I messed up with naming. It should be contribution_items = set()
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Problem regarding returning list sl33k <ahsanbagwan@gmail.com> - 2011-04-03 00:12 -0700 Re: Problem regarding returning list sl33k <ahsanbagwan@gmail.com> - 2011-04-03 00:17 -0700 Re: Problem regarding returning list Ian Kelly <ian.g.kelly@gmail.com> - 2011-04-03 02:02 -0600
csiph-web