Next / Previous / Contents / Shipman's homepage

9.5. FoDim.__mul__(): Multiply by a constant

We implement the multiply operator only for cases where the right-hand operator is a number (not a FoDim). A length times a length is an area, but this class deals only in lengths.

fohelpers.py
# - - -   F o D i m . _ _ m u l _ _

    def __mul__ ( self, other ):
        '''Multiply self by a constant.
        '''
        return FoDim ( self.n * Decimal(other), self.units )