Skip to main content

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.

I tried this way. apparently works fine (python 3.1.2):

to test if the variable, myvar, is defined  :

result = dir().count('myvar')

if myvar is defined, result is 1, otherwise it would be 0.

To test if the variable, myvar, is defined:

result = dir().count('myvar')

If myvar is defined, result is 1, otherwise it would be 0.

This works fine in Python version 3.1.2.

Source Link
sina651
  • 119
  • 1
  • 2

I tried this way. apparently works fine (python 3.1.2):

to test if the variable, myvar, is defined :

result = dir().count('myvar')

if myvar is defined, result is 1, otherwise it would be 0.