Entering edit mode
13.1 years ago
Martin
▴
30
If I try to run this script:
#imports
import Bio
#Give ncbi your e-mail
Bio.Entrez.email='no.name@acompany.com'
I get an surprising error:
Traceback (most recent call last):
File "bio_error.py", line 9, in <module>
Bio.Entrez.email='no.name@acompany.com'
AttributeError: 'module' object has no attribute 'Entrez'
Bu if I use:
#imports
import Bio
from Bio import Entrez
#Give ncbi your e-mail
Bio.Entrez.email='no.name@acompany.com'
It works fine, why?
That's exactly right. This isn't Biopython specific; that is how imports work in Python. Doing 'import Bio' does not recursively import individual modules. This improves speed by only importing necessary modules, at the small cost of needing to be explicit about the imports.