"""
Script: empty_tests.py
Modified: 2015-05-25
Purpose:
checks on objects that I use, that have a __len__ property
Notes:
- collections.OrderedDictionary and other classes in collections behave
in a similar fashion
- for NumPy arrays, use size property rather than __len__
"""
import numpy as np
import collections
c0 = collections.Counter()
c1 = collections.Counter([0])
objs = [ [],[1],(),(1),{},{1:"one"},"","1",None,True,1,False,0,c0,c1 ]
is_empty = [ True if not i else False for i in objs ]
t = [ type(i).__name__ for i in objs ] # correct based on comment
#t = [str(type(i)).split("\'")[1] for i in objs ] # line in question
print("\n{:<15} {:<6} {:<10}".format("Object","Empty","Type"))
for i in range(len(objs)):
print("{:<15} {:<6} {:<10s}".format(objs[i],str(is_empty[i]),t[i]))
Output with the above...the commented out line worked
EDIT
the "name" property wasn't listed where I thought it would be, so if the object has a "format" property, check there.