“cmd.get_names” returns a list of object and/or selection names.
cmd.get_names( [string: "objects"|"selections"|"all"|"public_objects"|"public_selections"] )
def get_names(type='public_objects',enabled_only=0,selection=""):
api