to¶
- Length.to(target_unit: str, inplace: bool = False) Length
It converts actual
valueto a new value computed usingtarget_unitas the reference unit of measurement.If
inplaceisTrue, it overrides actualvalueandunit, otherwise it returns a new instance with the convertedvalueand thetarget_unitasunit.Parameters¶
Returns¶
LengthConverted length.
Raises
Examples
Lengthinstantiation.>>> from gearpy.units import Length >>> l = Length(1, 'm') >>> l 1 m
Conversion from meter to centimeter with
inplace=Falseby default, so it does not override the current value.>>> l.to('cm') 100.0 cm >>> l 1 m
Conversion from meter to centimeter with
inplace=True, in order to override the current value.>>> l.to('cm', inplace=True) 100.0 cm >>> l 100.0 cm