trouble testing for existance of variable

googlePoster scott2237 at yahoo.com
Tue Mar 12 16:52:01 EST 2002


python gurus:

if I want to know if a variable exists before
testing it, what do I do?

I have tried 

   if locals().has_key("colors_name")

and

   if globals().has_key("colors_name")

and

   curr_color = "none"
   curr_color = vim.eval("colors_name")

and

   curr_color = os.getenv("colors_name", "none")

and I just can't seem to get there from here

I am using python as my gvim scripting language here,
python v2.2, both on NT 4.0 and win98se

gvim is version 6.0

I want to do things based on the existance of colors_name,
but if it's undefined I can't test it



More information about the Python-list mailing list