Next / Previous / Contents / Shipman's homepage

34.2. Spec4Field.flatten()

Because the class invariant states that the .spec4 attribute is always a four-letter code, flattening the code does not change its value. However, we do need to address the case of records with no species code, in which case the argument will be None.
# - - -   S p e c 4 F i e l d . f l a t t e n   - - -

    def flatten(spec4):
        '''Flatten a species code.
        if  spec4 is None:
            return  BLANK_SPEC4
            return  spec4.value