pymel.core.general.objExists

objExists(*args, **kwargs)

This command simply returns true or false depending on whether an object with the given name exists.

Derived from mel command maya.cmds.objExists

Example:

import pymel.core as pm

# Select an object if and only if it exists.
# Print a warning if it does not exist.
if pm.objExists('surface1'):
  pm.select('surface1')
else:
  print("Warning: no surface exists.")