class documentation

class Decimal(Argument): (source)

View In Hierarchy

Encodes decimal.Decimal instances.

There are several ways in which a decimal value might be encoded.

Special values are encoded as special strings:

  - Positive infinity is encoded as C{"Infinity"}
  - Negative infinity is encoded as C{"-Infinity"}
  - Quiet not-a-number is encoded as either C{"NaN"} or C{"-NaN"}
  - Signalling not-a-number is encoded as either C{"sNaN"} or C{"-sNaN"}

Normal values are encoded using the base ten string representation, using engineering notation to indicate magnitude without precision, and "normal" digits to indicate precision. For example:

  - C{"1"} represents the value I{1} with precision to one place.
  - C{"-1"} represents the value I{-1} with precision to one place.
  - C{"1.0"} represents the value I{1} with precision to two places.
  - C{"10"} represents the value I{10} with precision to two places.
  - C{"1E+2"} represents the value I{10} with precision to one place.
  - C{"1E-1"} represents the value I{0.1} with precision to one place.
  - C{"1.5E+2"} represents the value I{15} with precision to two places.

http://speleotrove.com/decimal/ should be considered the authoritative specification for the format.

Method from​String Convert a string to a Python object. Subclasses must implement this.
Method to​String Serialize a decimal.Decimal instance to the specified wire format.

Inherited from Argument:

Method __init__ Create an Argument.
Method from​Box Populate an 'out' dictionary with mapping names to Python values decoded from an 'in' AmpBox mapping strings to string values.
Method from​String​Proto Convert a string to a Python value.
Method retrieve Retrieve the given key from the given dictionary, removing it if found.
Method to​Box Populate an 'out' AmpBox with strings encoded from an 'in' dictionary mapping names to Python values.
Method to​String​Proto Convert a Python object to a string.
Instance Variable optional Undocumented
def fromString(self, inString): (source)
Convert a string to a Python object. Subclasses must implement this.
Parameters
in​String:bytesthe string to convert.
Returns
the decoded value from inString
def toString(self, inObject): (source)
Serialize a decimal.Decimal instance to the specified wire format.