<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Tahoma;
        color:green;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=blue style='word-wrap: break-word;-webkit-nbsp-mode: space;
-webkit-line-break: after-white-space'>

<div class=Section1>

<p class=MsoNormal><font size=2 color=green face=Tahoma><span style='font-size:
10.0pt;font-family:Tahoma;color:green'>That worked great, thanks.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=green face=Tahoma><span style='font-size:
10.0pt;font-family:Tahoma;color:green'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b><span
style='font-weight:bold'>On Behalf Of </span></b>Kenneth Miller<br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, November 05, 2008
7:46 AM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName w:st="on">Discussion
 of IronPython</st1:PersonName><br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [IronPython] How do I
test if a variable is defined?</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Can't you just do..<o:p></o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>'variable_name' in locals()<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>or<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>'variable_name' in dir()<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Regards,<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Ken<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>On Nov 5, 2008, at 4:07 AM, Michael Foord wrote:<o:p></o:p></span></font></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
<br>
<o:p></o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Tony Meyer wrote:<br>
<br>
<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>On Wed, Nov 5, 2008 at 8:06 AM, Michael Foord &lt;<a
href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>&gt;
wrote:<o:p></o:p></span></font></p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Marty Nelson wrote:<o:p></o:p></span></font></p>

</blockquote>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;&nbsp;&nbsp;<o:p></o:p></span></font></p>

</blockquote>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>How do I test in Iron Python (in python) if a variable is defined?<o:p></o:p></span></font></p>

</blockquote>

</blockquote>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</blockquote>

</blockquote>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<o:p></o:p></span></font></p>

</blockquote>

</blockquote>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>[...]<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>try:<o:p></o:p></span></font></p>

</blockquote>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;name<o:p></o:p></span></font></p>

</blockquote>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>except NameError:<o:p></o:p></span></font></p>

</blockquote>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;# variable 'name' is not defined<o:p></o:p></span></font></p>

</blockquote>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;&nbsp;&nbsp;<o:p></o:p></span></font></p>

</blockquote>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>If you're running some sort of checker (pylint, pychecker) over this,<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>you might get a warning about the &quot;name&quot; line not doing
anything. &nbsp;To<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>avoid that, you'll sometimes see a variant like this:<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>try:<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;&nbsp;&nbsp;unused = name<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>except NameError:<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;&nbsp;&nbsp;# variable 'name' is not defined.<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</blockquote>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
Except then PyLint will complain that 'unused' is unused, plus you code no
longer accurately conveys its intent.<br>
<br>
I prefer to filter (or disable) that particular warning rather than change the
code.<br>
<br>
Michael<br>
<br>
<br>
<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Cheers,<o:p></o:p></span></font></p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Tony<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>_______________________________________________<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Users mailing list<o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></span></font></p>

</blockquote>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt' type=cite>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</blockquote>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
<br>
-- <br>
<a href="http://www.ironpythoninaction.com/">http://www.ironpythoninaction.com/</a><br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com<o:p></o:p></span></font></p>

</div>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</div>

</body>

</html>

<table><tr><td bgcolor=#ffffff><font color=#000000>=======<br>
Notice: This e-mail message, together with any attachments, contains<br>
information of Symyx Technologies, Inc. or any of its affiliates or<br>
subsidiaries that may be confidential, proprietary, copyrighted,<br>
privileged and/or protected work product, and is meant solely for<br>
the intended recipient. If you are not the intended recipient, and<br>
have received this message in error, please contact the sender<br>
immediately, permanently delete the original and any copies of this<br>
email and any attachments thereto.<br>
</font></td></tr></table>