Tim Peters added the comment:

I'd rather see `i.bits_at(pos, width=1)`, to act like

(i >> pos) & ((1 << width) - 1)

That is, extract the `width` consecutive bits at positions 2**pos through 
2**(pos + width - 1) inclusive.

Because Python ints maintain the illusion of having an infinite number of sign 
bits, I don't think negative `pos` (or `width`) can be assigned a sensible 
meaning.  Python ints only have "one end".

And, yup, I've often wanted this too!

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19915>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to