[Biopython-dev] Code review request for phyloxml branch

Eric Talevich eric.talevich at gmail.com
Sat Jan 9 23:38:29 UTC 2010


Hi,

Thanks for your comments. I've reorganized the modules like this:

Bio/Phylo/
    __init__.py, BaseTree.py, Newick.py, PhyloXML.py, Utils.py
    IO/
        __init__.py, NexusIO.py, NewickIO.py, PhyloXMLIO.py

Now "from Bio import Phylo" works for the common cases, and "from
Bio.Phylo.IO import PhyloXMLIO" etc. gives more direct access to the
parsers.

I renamed TreeIO to Phylo/IO -- keeping it uppercase because io is a
standard module in Py2.6+, Py2.7 changes the priority rules for
absolute vs. relative imports, and Py2.4 doesn't support the new
syntax for relative imports. I might change the other file names to
lower case before the next merge, though...

On Sat, Jan 9, 2010 at 10:15 AM, Michiel de Hoon <mjldehoon at yahoo.com> wrote:
>
> Rather than importing *, can we import only those functions that a user would actually use? We should avoid importing stuff that is essentially used only locally in each sub-module.
>
> Another option is to have all functions that are intended to be used by the user in Bio.Phylo, and have those function access (internally) any sub-module as needed. For example, a user would not notice that Bio.Phylo.read actually uses code from Bio.Phylo.io; the latter module would not be accessed directly by the user.
>

I'm trying to avoid having to update Phylo/__init__.py each time I add
or rename a public function in Utils.py or IO. So, how about this:
I've added "__all__" definitions to Utils.py and IO/__init__.py so
that only the relevant public functions are loaded when
Phylo/__init__.py imports * from those two sub-modules. Testing
manually, this seems to do the right thing.

Cheers,
Eric




More information about the Biopython-dev mailing list