hkhr hkhr - 5 months ago 26
Python Question

print list in proper way python

I have a list "values" it has the types information i just to print it properly

in ipython notebook i am trying to print


> print values
[<type 'str'>, <type 'str'>, <type 'str'>, <type 'str'> <type 'int'>]

case2:but if i simply do

[str, str, str, str, int]

Ultimately i just case2 way of printing and tried to do it many ways but not getting it.


You have a list of type objects, and both __str__ and __repr__ of type objects have a <type 'x'> form.

If you want to print list of names of type objects you need to perform conversion manually:

print [t.__name__ for t in values]