Add method to return Bytes or Bits object as hex string #1
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Groesz.org/bits#1
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
for Bits:
return "0\x%02x" % self
for Bytes:
retvalue = "0x"
for Bits in self:
retvalue += "%02x" % Bits
for both classes, add a "hex" method which calls bytes(self).hex(). Add option to include a separator between each byte.
This can currently be done by casting the Bits/Bytes object to bytes and calling the hex() method. Adding the method to the bits classes allows them to be used similarly to the built-in bytes class. The optional "sep=" can be used to specify a separator charactor.
It appears the built-in bytes.hex() method already includes 'sep' and 'bytes_per_sep' arguments. Therefore, the Bytes and Bits methods can simply be:
resolved by
c63d2dd4bb