Skip to content

Commit 0914d16

Browse files
author
Robin Gottfried
committed
added xor operator
1 parent a8d096f commit 0914d16

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

bitint.py

+7
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def bitint(typename, value_names):
8282
>>> x &= 1
8383
>>> x
8484
B('first')
85+
>>> x ^= 1
86+
>>> x
87+
B()
8588
8689
"""
8790

@@ -125,6 +128,9 @@ def __contains__(self, value):
125128
def __or__(self, value):
126129
return self.__class__(int.__or__(self, value))
127130

131+
def __xor__(self, value):
132+
return self.__class__(int.__xor__(self, value))
133+
128134
def __and__(self, value):
129135
return self.__class__(int.__and__(self, value))
130136

@@ -152,6 +158,7 @@ def _unset(self, *bits):
152158
'__str__': __str__,
153159
'__iter__': __iter__,
154160
'__or__': __or__,
161+
'__xor__': __xor__,
155162
'__and__': __and__,
156163
'__invert__': __invert__,
157164
'__format__': __format__,

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "bitint"
3-
version = "0.1.1"
3+
version = "0.1.4"
44
description = "Pure Python implementation of extended integer with named bits."
55
authors = [
66
{name = "Robin Gottfried", email = "[email protected]"},

0 commit comments

Comments
 (0)