Next / Previous / Contents / Shipman's homepage

9. class Truths

An instance of this class represents a complete truth table. Here is the class interface.

# - - - - -   c l a s s   T r u t h s

class Truths(object):
    '''Represents a truth table.

          [ lineList is a list of strings ->
              if lineList is a valid truth table ->
                return a new Truths instance representing lineList
              else -> raise Value Error ]
          [ generate a sequence of strings, where each string represents
            one possible combination of conditions that is either
            uncovered or multiply-covered ]

Internal to this class are two invariants. The ._condList attribute is where we store the true, false, or don't-care values from the input. The ._caseCount attribute is the number of cases, which is the same as the number of columns in each input line (ignoring the optional comment tail).

          [ list of strings, one per condition, containing characters
            in TRUTH_CODES, such that element [k] is the truth value
            for that condition in case [k], and all strings have
            length self._caseCount ]
          [ number of cases in self ]