get a list printed in hexadecimal notation
Harvey Thomas
hst at empolis.co.uk
Wed Jul 17 08:57:51 EDT 2002
Oliver Eichler wrote:
> Sent: 17 July 2002 11:08
> To: python-list at python.org
> Subject: get a list printed in hexadecimal notation
>
>
> 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. Is there an
> easy way?
>
> Oliver
>
print [type(x) == type(1) and hex(x) or x for x in l]
Harvey
_____________________________________________________________________
This message has been checked for all known viruses by the MessageLabs Virus Scanning Service.
More information about the Python-list
mailing list