trouble testing for existance of variable
Carel Fellinger
cfelling at iae.nl
Wed Mar 13 17:39:06 EST 2002
googlePoster <scott2237 at yahoo.com> wrote:
...
> try:
> curr_color = vim.eval("colors_name")
> except NameError:
Ah code, now we know:) It's ofcourse not Python's fault, but incorrect
vim usage:) So I looked it up (don't use vim myself, but instructed my
daughters to:) and vim has this nifty function to check for the
existance of a varibale.
:echo eval("colors_name")
:python print eval("colors_name")
returns 0 or 1 depending on the existence of "colors_name", so why not:
curr_color = ( vim.eval( 'exists("colors_name")' )
and vim.eval('colors_name')
or None )
--
groetjes, carel
More information about the Python-list
mailing list