get a list printed in hexadecimal notation

Oliver Eichler oliver.eichler at dspsolutions.de
Wed Jul 17 11:35:35 EDT 2002


On Wednesday 17 July 2002 14:57, Harvey Thomas wrote:
> 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]
>

Groovy, this work! However it will take me the whole afternoon to figure out 
how ;)

Thanks 

Oliver


-- 
Ingenieure Kellermann, Voigt, Hoepfl, Eichler, Weidner und Klinger 

DSP Solutions                           http://www.dspsolutions.de







More information about the Python-list mailing list