I’m doing a bunch of work in the Python console, and most of it is referring to addresses, which I’d prefer to see in hex.
So if a = 0xBADF00D, when I simply enter Python> a into the console to view its value, I’d prefer python to reply with 0xBADF00D instead of 195948557.
I know I can enter '0x%X' % a to see it in hex, but I’m looking for some sort of python console option to have it do this automatically. Does something liket this exist? Thanks!
The regular Python interpreter will call
sys.displayhookto do the actual displaying of expressions you enter. You can replace it with something that displays exactly what you want, but you have to keep in mind that it is called for all expressions the interactive interpreter wants to display:I suspect you’ll quickly get tired of seeing all integers as hex, though, and switch to explicitly converting the ones you want to see as hex accordingly.