Existance of of variable

Roy Smith roy at panix.com
Mon Jul 4 20:25:11 EDT 2005


Steven D'Aprano <steve at REMOVETHIScyber.com.au> wrote:
> Should we *really* be encouraging newbies to mess with globals() and
> locals()? Isn't that giving them the tools to shoot their foot off before
> teaching them how to put shoes on?

Why risk damaging perfectly good footwear?

But, seriously, I agree with you.  The cannonical way to tell if a variable 
exists in Python is to try to access it and catch any resulting NameError.



More information about the Python-list mailing list