Does Python need a '>>>' operator?
Bengt Richter
bokr at oz.net
Tue Apr 16 03:21:01 EDT 2002
On Tue, 16 Apr 2002 14:03:12 +1200, Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
>Bengt Richter wrote:
>>
>> newhex(+7) => 0x7 # implied extension of msb => 0x000...007
>> newhex(-7) => 0x9 # implied extension of msb => 0xfff...ff9
>
>I think that would be very confusing. It's pretty
>subtle that the MSB of the binary equivalent of the
>first hex digit tells you whether the original number
>was positive or negative.
Familiarity breeds private illusions of clarity, I guess ;-)
I accept your point.
>
>If we were to have something like this, I would rather
>see
>
> newhex(+7) => 0x07
> newhex(-7) => 0xF9
>
>i.e. the leading hex digit is always either 0 or F.
>
An excellent suggestion!
Unfortunately, we have to worry about backwards compatibility, though,
so it might have to be introduced with 0h prefix instead of 0x.
>Then I would also want an extra arg to hex() for
>specifying how many digits I want.
>
Fine with me, too, if default is normalized to minimal prefixing.
Regards,
Bengt Richter
More information about the Python-list
mailing list