Table of Contents

Module: listfns Bio/Tools/listfns.py

This provides useful general functions for working with lists.

Functions: asdict Make the list into a dictionary (for fast testing of membership). items Get one of each item in a list. count Count the number of times each item appears. contents Calculate percentage each item appears in a list. itemindex Make an index of the items in the list. intersection Get the items in common between 2 lists. difference Get the items in 1 list, but not the other.

Functions   
asdict
contents
count
difference
intersection
itemindex
items
  asdict 
asdict ( l )

asdict(l) -> dictionary

Return a dictionary where the keys are the items in the list, with arbitrary values. This is useful for quick testing of membership.

  contents 
contents ( items )

contents(items) -> dict of item:percentage

Summarize the contents of the list in terms of the percentages of each item. For example, if an item appears 3 times in a list with 10 items, it is in 0.3 of the list.

  count 
count ( items )

count(items) -> dict of counts of each item

Count the number of times each item appears in a list of data.

  difference 
difference ( l1,  l2 )

difference(l1, l2) -> list of items in l1, but not l2

Return a list of the items in l1, but not l2. The list is in arbitrary order.

  intersection 
intersection ( l1,  l2 )

intersection(l1, l2) -> list of common items

Return a list of the items in both l1 and l2. The list is in arbitrary order.

  itemindex 
itemindex ( l )

itemindex(l) -> dict of item : index of item

Make an index of the items in the list. The dictionary contains the items in the list as the keys, and the index of the first occurrence of the item as the value.

  items 
items ( l )

items(l) -> list of items

Generate a list of one of each item in l. The items are returned in arbitrary order.


Table of Contents

This document was automatically generated on Sat Jul 7 09:50:16 2001 by HappyDoc version r1_5