faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 2 people (100%) answered Yes

Entry

How can I make it so the interpreter defaults to hexidecimal output?

Jul 19th, 2000 02:29
unknown unknown, Jürgen Hermann


Problem:
what I mean is the following:
>>> i = 0xa
>>> print i
10
>>> i
10
what I really want is to get the following:
>>> i = 0xa
>>> i
0xa
Solution:
Then write a HexInt class that overloads __str__ and __repr__,
and use i = HexInt(0xa). I see no other way.