how can i check if a variable is set?

Rich Harkins rich at worldsinfinite.com
Tue Feb 5 14:51:16 EST 2002


How 'bout:

try:
	a			# Or _junk_unused_variable_=a
except NameError:
	a=0

Rich

On Tuesday 05 February 2002 02:50 pm, maximilianscherr wrote:
> how cna i check if a variable is set?
> like:
>
> if variable a doesn't exist then set it to 0
> if it exists do nothing...




More information about the Python-list mailing list