Next / Previous / Contents / Shipman's homepage

18. class Species: Definition of a species code

This class is just a container for the different fields from one line of a species authority file. It has a __str__() special method so that the fields can be displayed in error messages.

baseclasses.py
# - - - - -   c l a s s   S p e c i e s   - - - - -

class Species:
    '''Represents one species code.

      Exports:
        Species(spNo, spec4, spec6, eng):
          [ (spNo is a 5-digit species number as a string) and
            (spec4 is a 4-letter species code) and
            (spec6 is a 6-letter species code) and
            (eng is an English name) ->
              return a new Species object representing those
              values ]
        .spNo:      [ as passed to constructor, read-only ]
        .spec4:     [ as passed to constructor, read-only ]
        .spec6:     [ as passed to constructor, read-only ]
        .eng:       [ as passed to constructor, read-only ]
        .__str__(self):
          [ return a string representation of self ]
    '''

18.1. Species.__init__(): Constructor

A trivial constructor that simply stores its arguments away within the instance.

baseclasses.py
# - - -   S p e c i e s . _ _ i n i t _ _   - - -

    def __init__(self, spNo, spec4, spec6, eng):
        '''Species constructor
        '''
        self.spNo  = spNo
        self.spec4 = spec4
        self.spec6 = spec6
        self.eng   = eng