get a list printed in hexadecimal notation
Oliver Eichler
oliver.eichler at dspsolutions.de
Fri Jul 19 02:19:13 EDT 2002
Bengt Richter wrote:
> >>> l = ('spam',10,15,'more spam',['nested',65535,'spam'],'spam',255)
> ^ ^^^^^ ^
> >>> print [isinstance(x,int) and hex(x) or x for x in l]
> ['spam', '0xa', '0xf', 'more spam', ['nested', 65535, 'spam'], 'spam',
> ['0xff']
I never do such complicated things at home ;) But you are right for more
complex lists the one liner won't fit.
Oliver
More information about the Python-list
mailing list