Package Bio :: Module _utils
[hide private]
[frames] | no frames]

Module _utils

source code

Common utility functions for various Bio submodules.
Functions [hide private]
 
iterlen(items)
Count the number of items in an iterable.
source code
 
read_forward(handle)
Read through whitespaces, return the first non-whitespace line.
source code
 
trim_str(string, max_len, concat_char)
Truncate the given string for display.
source code
 
getattr_str(obj, attr, fmt=None, fallback='?')
Return string of the given object's attribute.
source code
 
find_test_dir(start_dir=None)
Find the absolute path of Biopython's Tests directory.
source code
 
run_doctest(target_dir=None, *args, **kwargs)
Run doctest for the importing module.
source code
Variables [hide private]
  __package__ = 'Bio'
Function Details [hide private]

iterlen(items)

source code 

Count the number of items in an iterable.

If the argument supports len(items), and some iterators do, then this returns len(items). Otherwise it will scan over the entries in order to count them.

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

>>> iterlen("abcde")
5
>>> iterlen(iter("abcde"))
5

getattr_str(obj, attr, fmt=None, fallback='?')

source code 

Return string of the given object's attribute.

Defaults to the given fallback value if attribute is not present.

find_test_dir(start_dir=None)

source code 

Find the absolute path of Biopython's Tests directory.

Arguments: start_dir -- Initial directory to begin lookup (default to current dir)

If the directory is not found up the filesystem's root directory, an exception will be raised.