extracting hex mant+exp from double?
Tim Peters
tim.one at home.com
Sun Jun 10 02:50:29 EDT 2001
[Mike C. Fletcher, on "_"]
> Has anyone ever used it since it was slipped in (save you, in this one
> case)?
I expect it's used heavily. For example, the first complaint of people who
use sys.displayhook is "hey! '_' doesn't work anymore!" (setting
__builtin__._ is done by the default display hook, so if you provide your
own display hook you have to do that yourself -- if you want it).
> I must be suspicious when a time machine is hanging around. I've
> never noticed code using it (that I can recall).
You'll never see a program using it. There's nothing special about "_" in
batch code (it's just another identifier there), it only has this meaning in
an interactive shell (specifically, the display hook is called only from the
body of the PRINT_EXPR opcode, which opcode is generated only in response to
interactive input).
> "practicality-beats-purity-ly y'rs" how does it apply? I mean, I can
> see maybe in interactive environments you might get cases where you
> forgot to put x = in front of the last value and could save a few
> seconds recalculation,
Bingo, and remember that not all shells support history -- reproducing the
last line typed can be a real pain in those. Some expressions have
side-effects too. In addition, in an interactive shell you often don't
*know* that you're going to want to do something to the last result until
you see its value, and then
>>> x = whatever
doesn't display the value.
> but otherwise it just seems like pointless magic.
There is no otherwise -- it's an interactive gimmick, and that's all. You
should try it! It's handy.
live-and-let-underscore-ly y'rs - tim
More information about the Python-list
mailing list