This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients anon, mark.dickinson, tim.peters
Date 2013-12-07.00:44:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1386377087.99.0.492690755043.issue19915@psf.upfronthosting.co.za>
In-reply-to
Content
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!
History
Date User Action Args
2013-12-07 00:44:48tim.peterssetrecipients: + tim.peters, mark.dickinson, anon
2013-12-07 00:44:47tim.peterssetmessageid: <1386377087.99.0.492690755043.issue19915@psf.upfronthosting.co.za>
2013-12-07 00:44:47tim.peterslinkissue19915 messages
2013-12-07 00:44:47tim.peterscreate