(self, new_units)
| 19 | self.units = units |
| 20 | |
| 21 | def to(self, new_units): |
| 22 | factors = {('hours', 'seconds'): 3600, ('minutes', 'hours'): 1 / 60, |
| 23 | ('minutes', 'seconds'): 60, ('feet', 'miles'): 1 / 5280., |
| 24 | ('feet', 'inches'): 12, ('miles', 'inches'): 12 * 5280} |
| 25 | if self.units != new_units: |
| 26 | mult = factors[self.units, new_units] |
| 27 | return Quantity(mult * self.magnitude, new_units) |
| 28 | else: |
| 29 | return Quantity(self.magnitude, self.units) |
| 30 | |
| 31 | def __copy__(self): |
| 32 | return Quantity(self.magnitude, self.units) |