IssueString
IssueString(text: str | float | None)
Handles issue number strings by breaking them into numeric and suffix parts, and provides methods to convert to different formats.
This class parses comic book issue numbers that can contain various formats including decimals, negative numbers, and alphanumeric suffixes.
Examples:
>>> issue = IssueString("12.5AU")
>>> issue.num
12.5
>>> issue.suffix
'AU'
>>> issue.as_string(pad=3)
'012.5AU'.
Initialize an IssueString object by parsing the input text.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The issue number to parse. Can be string, int, float, or None.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If text is not a supported type. |
Functions
__eq__(other: object) -> bool
Check equality with another IssueString or comparable object.
__hash__() -> int
Return hash value for the IssueString object.
This enables IssueString objects to be used in sets and as dictionary keys. The hash is based on both the numeric value and suffix components.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Hash value based on the num and suffix attributes. |
__lt__(other: IssueString) -> bool
Compare IssueString objects for sorting.\n Comparison priority: 1. Numeric value (None is treated as 0) 2. Suffix (alphabetical).
__repr__() -> str
Return detailed string representation for debugging.
__str__() -> str
Return string representation without padding.
as_float() -> float | None
Return the numeric value as a float.\n Special handling for the half symbol (½) which adds 0.5 to the base number.
Examples:
>>> IssueString("12½").as_float()
12.5
>>> IssueString("5").as_float()
5.0
| RETURNS | DESCRIPTION |
|---|---|
float | None
|
Float value of the issue number, or None if no numeric part exists. |
as_int() -> int | None
Return the integer portion of the numeric value.
Examples:
>>> IssueString("12.7").as_int()
12
>>> IssueString("AU").as_int()
None
| RETURNS | DESCRIPTION |
|---|---|
int | None
|
Integer value (truncated, not rounded) or None if no numeric part. |
as_string(pad: int = 0) -> str
Return a string representation with optional zero padding.\n Examples: >>> IssueString("5.2").as_string(pad=3) '005.2' >>> IssueString("-12AU").as_string(pad=4) '-0012AU'.
| PARAMETER | DESCRIPTION |
|---|---|
pad
|
Number of digits to pad the integer part with leading zeros.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
String representation of the issue number with padding and suffix. |
has_suffix() -> bool
Check if the issue string has a non-empty suffix.
is_numeric_only() -> bool
Check if the issue string contains only numeric content.