Is Biopython a Package or Library?
1
0
Entering edit mode
3.6 years ago
anasjamshed ▴ 140

I am confused between libraries and packages of python. Modules are python files with .py extension and when we combine different modules in some folder then it becomes a package. A combination of packages will make a library.

Pypi is python package manager so as the name suggests it contains packages, not libraries. But as I saw on the internet many people saying that biopython is a library although it is present in PyPi.

Can anyone solve my query?

Biopython Python • 1.6k views
ADD COMMENT
1
Entering edit mode

These terms are generally used by the public interchangeably and one would be called pedantic for correcting others one way or another, so there's no strict definition IMO.

My thinking is that unless you can import Biopython, it is a library (collection) of individual packages that you import.

I think this is a question for the Stack Exchange community though, as it concerns software architecture nomenclature.

ADD REPLY
3
Entering edit mode
3.6 years ago

"Library" is a generic term that describes a type of software that you make use of within your programs rather than running the software alone.

Libraries can be implemented in different ways, in Python a library could be a module or one or more packages.

A module is a python file.

A package is a collection of modules (files) in a directory.

Biopython is a package, though the naming is somewhat confusing. When you do a

from Bio.Seq import Seq

you are importing the Seq class (the word listed last) of the Seq module located in the Bio package.

So, on your computer somewhere there will be a folder and file called:

Bio/Seq.py

then inside that Seq.py there is a line like so:

class Seq
      ...

Biopython stands out in the oddness of its naming scheme, it precedes most modern naming schemes hence inherits quite the baggage here.

ADD COMMENT
0
Entering edit mode

If we were to rename the py file to Seq2.py, would the import statement change to from Bio.Seq2 import Seq?

ADD REPLY
0
Entering edit mode

correct,

in the more "modern" naming schemes we recommend lowercasing modules and title-case classes to better communicate their type, if biopython were rewritten to that scheme the import would look like this:

from bio.seq import Seq

in addition, since some platforms are case insensitive (Windows and MacOS) Seq.py and seq.py would be the same file, thus mixing cases in filenames can lead to all kinds of bugs and potential unintended consequences. hence best to stick with all lower case.

ADD REPLY

Login before adding your answer.

Traffic: 2014 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6