Bottom Page

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]
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#2
Try
type([]).__name__
Gribouillis and Skaperen like this post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Type hinting - return type based on parameter micseydel 2 92 Jan-14-2020, 01:20 AM
Last Post: micseydel
  Object of type set is not JSON serializable enigma619 5 316 Dec-19-2019, 03:30 PM
Last Post: enigma619
  Object of type Scoreboard is not JSON serializable lsepolis123 9 2,372 Aug-13-2019, 11:22 AM
Last Post: lsepolis123
  Object and type class Uchikago 2 234 Jul-28-2019, 10:35 AM
Last Post: DeaD_EyE
  Object type of Node to json bhojendra 4 638 Apr-28-2019, 01:36 PM
Last Post: bhojendra
  TypeError: object of type 'NoneType' has no len() - what do it mean? leviathan54 4 2,328 Apr-20-2019, 12:04 PM
Last Post: leviathan54
  Getting error "Type error-a bytes-like object..." mrapple2020 1 1,887 Apr-06-2019, 06:37 PM
Last Post: mrapple2020
  scatter plot error - possibly data type - TypeError: nan is not a string chudson 1 1,573 Mar-24-2019, 11:48 AM
Last Post: chudson
  string to list and back again as same type Skaperen 10 1,255 Sep-06-2018, 08:26 PM
Last Post: Skaperen
  Variant type object arrays anbra 3 1,290 Jul-29-2018, 09:25 PM
Last Post: anbra

Forum Jump:


Users browsing this thread: 1 Guest(s)