That worked great, thanks.
________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kenneth Miller
Sent: Wednesday, November 05, 2008 7:46 AM
To: Discussion of IronPython
Subject: Re: [IronPython] How do I test if a variable is defined?
Can't you just do..
'variable_name' in locals()
or
'variable_name' in dir()
Regards,
Ken
On Nov 5, 2008, at 4:07 AM, Michael Foord wrote:
Tony Meyer wrote:
On Wed, Nov 5, 2008 at 8:06 AM, Michael Foord
<[EMAIL PROTECTED]> wrote:
Marty Nelson wrote:
How do I test in Iron Python (in python) if a
variable is defined?
[...]
try:
name
except NameError:
# variable 'name' is not defined
If you're running some sort of checker (pylint, pychecker) over
this,
you might get a warning about the "name" line not doing
anything. To
avoid that, you'll sometimes see a variant like this:
try:
unused = name
except NameError:
# variable 'name' is not defined.
Except then PyLint will complain that 'unused' is unused, plus you code
no longer accurately conveys its intent.
I prefer to filter (or disable) that particular warning rather than
change the code.
Michael
Cheers,
Tony
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
--
http://www.ironpythoninaction.com/
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
=======
Notice: This e-mail message, together with any attachments, contains
information of Symyx Technologies, Inc. or any of its affiliates or
subsidiaries that may be confidential, proprietary, copyrighted,
privileged and/or protected work product, and is meant solely for
the intended recipient. If you are not the intended recipient, and
have received this message in error, please contact the sender
immediately, permanently delete the original and any copies of this
email and any attachments thereto.
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com