pyppin.text.sign¶
Common classes for printf-like sign-printing conventions.
Functions
|
Apply a Sign to a formatted number. |
Classes
|
Equivalent to printf's "-" option, controlling when plus and minus signs should be shown. |
- class pyppin.text.sign.Sign(value)[source]¶
Bases:
Enum
Equivalent to printf’s “-” option, controlling when plus and minus signs should be shown.
- NEGATIVE_ONLY = 0[source]¶
show signs only for negative numbers.
- Type
The default, equivalent to printf -
- POSITIVE_AND_NEGATIVE = 1[source]¶
Show signs for both positive and negative numbers.
- Type
Equivalent to printf +
- pyppin.text.sign.format_sign(formatted_unsigned: str, sign_mode: Sign, is_negative: bool) str [source]¶
Apply a Sign to a formatted number.
- Parameters
formatted_unsigned – The number as rendered, not including any sign information. (i.e., a rendering of the absolute value of the number)
sign_mode – How signs should be attached to the number.
is_negative – Whether the number is negative.
- Returns
The number formatted with the correct sign.