One way, define the object before it is used, like this: object = None ..... ..... if object is not None: object.method() The other way, using try ... catch try: object.method() catch NameError: pass for big programs, which is better, or any other way? Miles