Next / Previous / Contents / Shipman's homepage

9.4. The Taxon class: One node in the classification tree

Each instance of a Taxon object represents one taxon. These objects make up the tree representing the taxonomic arrangement.

See Section 9.1, “Class Txny: the complete system” for various ways to obtain Taxon objects corresponding to a given scientific name, bird code, or taxonomic key number.

Attributes of a Taxon object:


A pointer back to the Txny object in which this taxon is located.


The standard bird code, if this taxon has one. Higher ranks such as families and orders may not have a standard code.


The English name of the taxon, as a string.


The English name of the taxon, as a string, but with multi-word names inverted as “last, first”, e.g., “Owl, Great Gray” instead of “Great Gray Owl”.


For the root taxon, this attribute is None. For the other taxa in the tree, it points to the taxon that has this taxon as a child.


The rank of this taxon, as a Rank object.


The scientific name of the taxon, as a string.


The status code for this taxon. For the values of status codes, see Section 5.2.2, “ Species records in the .std file ”.


Normally, this attribute has a value of None. However, if the English name of this taxon has markup (such as italics or non-ASCII characters), this attribute may contain the English name using TEX markup conventions.


The taxonomic key number for this taxon.

These methods are available on Taxon objects:


If t2 is another Taxon object in the same Txny, this predicate tests whether self contains t2.


If t2 is another Taxon object in the same Txny, this method returns the nearest ancestor of self and t2 as a Taxon object.


If desc is a Taxon descended from self, this method returns the child of self that contains desc.

If desc is not a descendant of self, the method raises ValueError.

.__cmp__(self, other)

This method implements the cmp() function for comparing two Taxon objects. The comparison is in phylogenetic order, that is, the taxon with the lower .txKey attribute will compare lower.

.__getitem__(self, n)

If 0 <= n < len(self), returns the nth child of self; otherwise it raises KeyError. This method is called when a Taxon object t is indexed as “t[n]”.


Defines the iter() function on a Taxon element. In constructs such as “for child in taxon”, this function returns an iterator that visits each child in order, 0, 1, ....


Returns the number of child taxa.