StringX.py defines a custom String class with advanced functionalities, surpassing Python's built-in string type. It offers enhanced string manipulation, including encoding/decoding, rule-based transformations, and custom exceptions.
The StringX.py
module defines a custom String
class, offering extended functionalities beyond Python’s built-in string type. The primary aim is to provide advanced string manipulation capabilities, including encoding/decoding mechanisms and rule-based transformations.
Advanced String Representation:
Overloaded Operators:
+
), multiplication (*
), and equivalence (==
).Enhanced String Operations:
count()
: Count occurrences of a substring.isupper()
: Check if the string is in uppercase.islower()
: Check if the string is in lowercase.Encoding/Decoding Capabilities:
Custom Exceptions:
String
class.String
value
: Represents the actual string content.bits
: Used in encoding/decoding operations.lenght
: Represents the length of the string (Note: This might be a typo, consider using Python’s len
function).stri_list
, pair_original
: Internal representations for specific operations.rules
: Contains rules for encoding/decoding.base64()
: Encode the string using Base64.Base64DecodeError
: Raised for errors during Base64 decoding.CyclicCharsError
: Raised for cyclic character-related errors.CyclicCharsDecodeError
: Raised for decoding errors related to cyclic characters.BytePairError
: Raised for byte pair-related errors.BytePairDecodeError
: Raised for decoding errors related to byte pairs.Instantiate the String
class with your desired string content and optional rules for transformations:
b = String('#d#ac', ['! = aa', '“ = !a', '# = “b'])
Invoke methods on the object to perform various operations:
print(b.decode_byte_pair())
print(b.decode_byte_pair().byte_pair_encoding())
(Note: Sample usage might vary based on the complete functionality of the module).
The String.py
module provides an enriched set of string manipulation tools, making it suitable for applications requiring advanced string processing capabilities.