0

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

in ipython notebook i am trying to print

case1:

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

case2:but if i simply do

 >values
  [str, str, str, str, int]

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

Lohith
  • 866
  • 1
  • 9
  • 25
  • What part are you having difficulty with? Don't know how to get the string `'str'` from the type object `str`? Don't know how to comma-separate a sequence of strings? – Steve Jessop Sep 23 '16 at 10:11
  • i am having problem with the first part, i want the output in form of second part [str, str, str, str, int] – Lohith Sep 23 '16 at 10:13

1 Answers1

4

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]
Łukasz Rogalski
  • 22,092
  • 8
  • 59
  • 93