Greg Ewing <[EMAIL PROTECTED]> writes: > I don't know about oct(), but I found hex() to be quite useful > the other day when I was using the interactive interpreter to > to some hex calculations. It would have been quite tedious > having to say "%x".format(_) or some such all the time to > see the results in hex. > > An alternative might be to have some variable that can be > set to control the format of numbers printed by the interactive > shell.
Something like this? >>> import sys >>> import __builtin__ >>> def myhook(o): ... if isinstance(o, int): ... print hex(o) ... else: ... print repr(o) ... __builtin__._ = o ... >>> sys.displayhook = myhook >>> 123 0x7b Bernhard _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com