get a list printed in hexadecimal notation

Michael Hudson mwh at python.net
Wed Jul 17 06:37:41 EDT 2002


Oliver Eichler <oliver.eichler at dspsolutions.de> writes:

> Hi
> 
> Is it possible to print a mixed list with strings and numbers and having the 
> numbers printed as hexadecimal notation?
> 
> something like:
> 
> >>>l = ('spam',10,15,'more spam')
> >>>print l
> ('spam',0xA,0xF,'more spam')
> 
> or similar...
> 
> The only way I could think of is to write my own print function. 

This is likely the case.

> Is there an easy way?

You may be able to leverage the pprint module.  Not sure.

Cheers,
M.

-- 
7. It is easier to write an incorrect program than understand a
   correct one.
  -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html



More information about the Python-list mailing list