[IPython-user] Can I configure ipython to output hex format for number?
Wong, Shin Guey
Tue Sep 23 07:36:55 CDT 2008
Thanks and it works!!! Appreciate for your help. :)
I think most ppl should like to have this kind of tweak and I agree that it should add in the documentation.
>From: Ville M. Vainio [mailto:email@example.com]
>Sent: Tuesday, September 23, 2008 4:37 PM
>To: Wong, Shin Guey
>Subject: Re: [IPython-user] Can I configure ipython to output hex format
>On Tue, Sep 23, 2008 at 9:46 AM, Wong, Shin Guey
>> I am using ipython to do some hardware validating stuff and require to
>read a lot of hex number. I have a lot functions which only return decimal
>value but when the ipython print it out at the console, I would like it to
>change it to hex format when it detected the return string is number. Is
>this doable in ipython?
>Yes. You can create a new result-displayer for integers by doing this:
>from IPython.generics import result_display
> print hex(i)
>print_hex = result_display.when_type(int)(print_hex)
>You might want to add this to your ipy_user_conf.py. Actually, this
>may be a good example to add to the documentation as well.
>Ville M. Vainio
More information about the IPython-user