Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
type of object as a string
#1
i need to get the type of an object as a string, as in [] -> 'list'. does anything already exist for this or do i need to use my own function?

def typestr(obj):
    return str(type(obj)).split("'")[1]
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
type of object as a string - by Skaperen - Dec-01-2019, 10:29 PM
RE: type of object as a string - by midarq - Dec-02-2019, 08:01 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  declaring object parameters with type JonWayn 2 903 Dec-13-2022, 07:46 PM
Last Post: JonWayn
  reading a table which is of type string saisankalpj 2 963 Dec-03-2022, 11:19 AM
Last Post: saisankalpj
  TypeError: int() argument must be a string, a bytes-like object or a number, not 'Non Anldra12 2 5,224 May-02-2021, 03:45 PM
Last Post: Anldra12
Star Type Error: 'in' object is not callable nman52 3 3,416 May-01-2021, 11:03 PM
Last Post: nman52
  TypeError: __str__ returned non-string (type tuple) Anldra12 1 7,415 Apr-13-2021, 07:50 AM
Last Post: Anldra12
  TypeError: 'type' object is not subscriptable Stef 1 4,534 Aug-28-2020, 03:01 PM
Last Post: Gribouillis
  How to convert a string "<... object at POINTER>" to an object? mandaxyz 5 3,656 Aug-08-2020, 10:44 PM
Last Post: mandaxyz
  isinstance() always return true for object type check Yoki91 2 2,570 Jul-22-2020, 06:52 PM
Last Post: Yoki91
  C-API for Python 3 - Get String from Object mga010 2 3,622 Jun-23-2020, 04:32 PM
Last Post: mga010
  TypeError: __repr__ returned non-string (type dict) shockwave 0 3,198 May-17-2020, 05:56 PM
Last Post: shockwave

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020