I tried this way. apparently works fine (python 3.1.2):
toTo test if the variable, myvar, is defined :
result = dir().count('myvar')
result = dir().count('myvar')
ifIf myvar is defined, result is 11, otherwise it would be 00.
This works fine in Python version 3.1.2.