Checking if variable exists in *Namespace* in Python

hasattr(ns, "name")

- or -

'name' in vars(ns)