MCPcopy Create free account
hub / github.com/ActiveState/code / __setslice__

Method __setslice__

recipes/Python/578922_bitfield_rev2/recipe-578922.py:25–31  ·  view source on GitHub ↗

set bits slice from start to end index (n-0) with the given value

(self, start, end, value)

Source from the content-addressed store, hash-verified

23 return ((self._d >> start) & mask)
24
25 def __setslice__(self, start, end, value):
26 "set bits slice from start to end index (n-0) with the given value"
27 mask = 2**(end - start + 1) -1
28 value = (value & mask) << start
29 mask = mask << start
30 self._d = (self._d & ~mask) | value
31 return (self._d >> start) & mask
32
33 def __int__(self):
34 "add de int() function for bf"

Callers 1

packMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected