Back to index

python-biopython  1.60
Functions | Variables
Bio.Phylo._sugar Namespace Reference

Functions

def iterlen
def trim_str

Variables

string __docformat__ = "restructuredtext en"

Function Documentation

def Bio.Phylo._sugar.iterlen (   items)
Count the number of items in an iterable.

Exhausts a generator, but doesn't require creating a full list.

Definition at line 13 of file _sugar.py.

00013 
00014 def iterlen(items):
00015     """Count the number of items in an iterable.
00016 
00017     Exhausts a generator, but doesn't require creating a full list.
00018     """
00019     for i, x in enumerate(items):
00020         count = i
00021     return count + 1
00022 

def Bio.Phylo._sugar.trim_str (   text,
  maxlen = 60 
)
Truncate a string to maxlen characters, including ellipsis.

Definition at line 23 of file _sugar.py.

00023 
00024 def trim_str(text, maxlen=60):
00025     """Truncate a string to maxlen characters, including ellipsis."""
00026     assert isinstance(text, basestring), \
00027             "%s should be a string, not a %s" % (text, type(text))
00028     if len(text) > maxlen:
00029         return text[:maxlen-3] + '...'
00030     return text

Variable Documentation

string Bio.Phylo._sugar.__docformat__ = "restructuredtext en"

Definition at line 10 of file _sugar.py.