I want to check if a variable exists. Now I\'m doing something like this:
try: myVar except NameError: # Do something.
Are there othe
for objects/modules, you can also
'var' in dir(obj)
For example,
>>> class Something(object): ... pass ... >>> c = Something() >>> c.a = 1 >>> 'a' in dir(c) True >>> 'b' in dir(c) False