Why would I get a TypeEror?
tjreedy at udel.edu
Wed Jan 12 19:34:48 EST 2005
"Peter Hansen" <peter at engcorp.com> wrote in message
news:XOOdnSCB9NmJ-HjcRVn-2w at powergate.ca...
> What did you expect the "length" of the integer 3 to be?
Perhaps 2 (bits in a minimal binary representation).
I once, for maybe a minute, considered proposing this as an overloaded
meaning of len, but realized that that would more often mask errors than
If case bits(i) is what the OP wants:
i = abs(i)
b = 0
i >>= 1
b += 1
Terry J. Reedy
More information about the Python-list