Next / Previous / Contents / Shipman's homepage

10. class Station: Represents one station

An object of this class represents one station.

baseclasses.py
# - - - - -   c l a s s   S t a t i o n   - - - - -

class Station:
    '''Represents one banding station in a given location.

      Exports:
        Station(loc, staNo, staName, staCode):
          [ (loc is a Location object) and
            (staNo is a station number as a string) and
            (staName is a station name) and
            (staCode is an alphabetic station code) ->
              return a new Station with those attributes ]
        .loc:           [ as passed to constructor, read-only ]
        .staNo:         [ as passed to constructor, read-only ]
        .staName:       [ as passed to constructor, read-only ]
        .staCode:       [ as passed to constructor, read-only ]
        .__str__(self):
          [ return a string representation of self ]
    '''

10.1. Station.__init__(): Constructor

All the constructor has to do is save its arguments.

baseclasses.py
# - - -   S t a t i o n . _ _ i n i t _ _   - - -

    def __init__(self, loc, staNo, staName, staCode):
        '''Constructor for Station.
        '''
        self.loc       = loc
        self.staNo     = staNo
        self.staName   = staName
        self.staCode   = staCode

The last three lines set the corresponding attributes to empty strings in case the arguments have the default values (None).