Size class, for creating instances of Size objects.
Contains a few documented methods and a number of __*__ methods implementing arithmetic operations. Precise numeric types such as int and Decimal may also occur in some arithmetic expressions, but all occurrances of floating point numbers in arithmetic expressions will cause an exception to be raised.
Bases: object
Class for instantiating Size objects.
Return a representation of this size, decomposed into a Fraction value and a unit specifier tuple.
Parameters: | |
---|---|
Returns: | a pair of a decimal value and a unit |
Return type: | tuple of Fraction and unit |
Raises SizeValueError: | |
if min_value is not usable |
The meaning of the parameters is the same as for _config.StrConfig.
Yield a representation of this size for every unit, decomposed into a Fraction value and a unit specifier tuple.
Parameters: | binary_units (bool) – binary units if True, else SI |
---|
Return the size in the units indicated by the specifier.
Parameters: | spec (a units specifier or Size) – a units specifier |
---|---|
Returns: | a numeric value in the units indicated by the specifier |
Return type: | fractions.Fraction |
Raises SizeValueError: | |
if unit specifier is non-positive |
Return a string representation of the size.
:param SizeConfig config: representation configuration :returns: a string representation :rtype: str
Returns: | the number of bytes |
---|---|
Return type: | Fraction |
Rounds to unit specified as a named constant or a Size.
Parameters: |
|
---|---|
Returns: | appropriately rounded Size |
Return type: | |
Raises SizeValueError: | |
on unusable arguments |
If unit is Size(0), returns Size(0).