class documentation

class twisted.protocols.amp.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 fromString Convert a string to a Python object. Subclasses must implement this.
Method toString Serialize a decimal.Decimal instance to the specified wire format.

Inherited from Argument:

Instance Variable optional Undocumented
Method __init__ Create an Argument.
Method retrieve Retrieve the given key from the given dictionary, removing it if found.
Method fromBox Populate an 'out' dictionary with mapping names to Python values decoded from an 'in' AmpBox mapping strings to string values.
Method toBox Populate an 'out' AmpBox with strings encoded from an 'in' dictionary mapping names to Python values.
Method fromStringProto Convert a string to a Python value.
Method toStringProto Convert a Python object to a string.
def fromString(self, inString): (source)

Convert a string to a Python object. Subclasses must implement this.

ParametersinStringthe string to convert. (type: bytes)
Returnsthe decoded value from inString
def toString(self, inObject): (source)

Serialize a decimal.Decimal instance to the specified wire format.

API Documentation for Twisted, generated by pydoctor 20.12.1 at 2021-02-28 19:53:36.