def dir2(obj):
 try:
  words = set(dir(obj))
 except Exception:
  words = set()
 words = [w for w in words if isinstance(w, str)]
 return sorted(words)

def dir2 ( obj ) : try : words = set ( dir ( obj ) ) except Exception : words = set ( ) words = [ w for w in words if isinstance ( w , str ) ] return sorted ( words )
dir2 -> list of strings extended version of the python builtin dir() .