The Encoder class stores the prefix code internally as self._codec.code but doesn't expose it as a public property. Users who need the prefix byte must access the private _codec attribute or call get_encoding_info().
Problem
enc = Encoder("base16")
enc.encoding # "base16" ✅ — name is public
enc.code # ❌ AttributeError — prefix byte not exposed
enc._codec.code # b"f" — works but accesses private attribute
Go's Encoder exposes the encoding code:
func (p Encoder) Encoding() Encoding {
return p.enc // Returns the Encoding constant (e.g., Base16 = 'f')
}
Proposed Solution
Add a code property to the Encoder class:
class Encoder:
@property
def code(self) -> bytes:
"""The multibase prefix byte for this encoding."""
return self._codec.code
Add tests and update __init__.py exports if needed.
Related
The
Encoderclass stores the prefix code internally asself._codec.codebut doesn't expose it as a public property. Users who need the prefix byte must access the private_codecattribute or callget_encoding_info().Problem
Go's
Encoderexposes the encoding code:Proposed Solution
Add a
codeproperty to theEncoderclass:Add tests and update
__init__.pyexports if needed.Related
Encoder.Encoding()method in go-multibaseencoder.go