get a list printed in hexadecimal notation

Fredrik Lundh fredrik at pythonware.com
Wed Jul 17 18:46:25 EDT 2002


François Pinard wrote:
>
> > print  [type(x) == type(1) and hex(x) or x for x in l]
>
> A tiny detail.  I guess that `type(x) == type(1)' is better written
> `isinstance(x, int)' under Python 2.2.

and as "isinstance(x, type(1))" for versions before 2.2, and as
"type(x) is type(1)" for versions before 1.5.

(replace type(1) with types.IntType where appropriate)

</F>





More information about the Python-list mailing list