UnitInfo

UnitInfo

class UnitInfo

UnitInfo provides functions to retrieve information concerning unit definitions

Convert(value, srcUnit, dstUnit)

Converts the given value from a source unit into the destination unit

Info

A unitless size (noUnit) cannot be converted.

Parameters:
value : float

Numeric value in source unit to be converted

srcUnit : str

Name of source unit

dstUnit : str

Name of destination unit

Returns:

Converted numeric value in destination unit, or None, if not convertable

Return type:

float or None

GetDimension(unitString)

Provides the dimension of a unit

Parameters:
unitString : str

Name of unit

Returns:

Dimension or None if unit unknown

Return type:

str or None

HasUnit(unitString)

Checks whether the unit is defined in the units definition file

Parameters:
unitString : str

Name of unit

Returns:

True or False

Return type:

bool