Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 type of object as a string
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]
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Skaperen and Gribouillis like this post

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  TypeError: 'type' object is not subscriptable Stef 1 182 Aug-28-2020, 03:01 PM
Last Post: Gribouillis
  How to convert a string "<... object at POINTER>" to an object? mandaxyz 5 319 Aug-08-2020, 10:44 PM
Last Post: mandaxyz
  isinstance() always return true for object type check Yoki91 2 252 Jul-22-2020, 06:52 PM
Last Post: Yoki91
  C-API for Python 3 - Get String from Object mga010 2 387 Jun-23-2020, 04:32 PM
Last Post: mga010
  TypeError: __repr__ returned non-string (type dict) shockwave 0 354 May-17-2020, 05:56 PM
Last Post: shockwave
  Why, TypeError: expected string or bytes-like object ? JohnnyCoffee 3 1,768 May-08-2020, 04:26 AM
Last Post: bowlofred
  converting string object inside a list into an intiger bwdu 4 336 Mar-31-2020, 10:36 AM
Last Post: buran
  AttributeError: type object 'FunctionNode' has no attribute '_TestValidateFuncLabel__ binhduonggttn 0 428 Feb-19-2020, 11:29 AM
Last Post: binhduonggttn
  TypeError: size; expecting a recognized type filling string dict a11_m11 0 423 Feb-10-2020, 08:26 AM
Last Post: a11_m11
  Type hinting - return type based on parameter micseydel 2 391 Jan-14-2020, 01:20 AM
Last Post: micseydel

Forum Jump:

Users browsing this thread: 1 Guest(s)