<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Define a function in Tool Class of PYT in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287863#M22257</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are trying to reference it at the class level without using self which won't work. You need to pass self to the function so the class can reference it, declare it within another function, or reference it outside the class.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Apr 2014 16:03:45 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2014-04-22T16:03:45Z</dc:date>
    <item>
      <title>Define a function in Tool Class of PYT</title>
      <link>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287862#M22256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm pretty sure this is possible and I'm just missing something relatively basic.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wrote a little function to do something (proprietary) and I want to leverage it within the execute function of a Python Toolbox. For the sake of keeping the code tidy, I'd like to define it within the Tool Class rather than within the Execute Function of the Tool Class. like so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def updateMessages(self, parameters): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the messages created by internal validation for each tool &amp;nbsp;&amp;nbsp;&amp;nbsp; parameter.&amp;nbsp; This method is called after internal validation.""" &amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp; def MyFunction(inFeatureLayer): &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(inFeatureLayer,&amp;nbsp; "NEW_SELECTION", '"ID" = ' + "'123456'") &amp;nbsp;&amp;nbsp;&amp;nbsp; SiteList = list(r[0] for r in arcpy.da.SearchCursor(inFeatureLayer, "ID")) &amp;nbsp;&amp;nbsp;&amp;nbsp; return SiteList&amp;nbsp; def execute(self, parameters, messages): &amp;nbsp;&amp;nbsp;&amp;nbsp; """The source code of the tool""" &amp;nbsp;&amp;nbsp;&amp;nbsp; inFeatureLayer = arcpy.parameters[0].valueAsText &amp;nbsp;&amp;nbsp;&amp;nbsp; Result = MyFunction(inFeatureLayer) # Why doesn???t this work??? &amp;nbsp;&amp;nbsp;&amp;nbsp; # Do something with the result&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I do that however, the Execute function doesn't see it. The only way I can get the execute function to see my function is by defining it within the execute function, like so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def updateMessages(self, parameters): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the messages created by internal validation for each tool &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parameter.&amp;nbsp; This method is called after internal validation.""" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp; def execute(self, parameters, messages): &amp;nbsp;&amp;nbsp;&amp;nbsp; """The source code of the tool""" &amp;nbsp;&amp;nbsp;&amp;nbsp; def MyFunction(inFeatureLayer): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(inFeatureLayer,&amp;nbsp; "NEW_SELECTION", '"ID" = ' + "'123456'") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SiteList = list(r[0] for r in arcpy.da.SearchCursor(inFeatureLayer, "ID") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return SiteList&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; inFeatureLayer = arcpy.parameters[0].valueAsText &amp;nbsp;&amp;nbsp;&amp;nbsp; Result = MyFunction(inFeatureLayer) # This works, but it seems more elegant to me if I could define it outside of Execute &amp;nbsp;&amp;nbsp;&amp;nbsp; # Do something with the result&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This seems like it should be wholly possible. What I am doing wrong?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Apr 2014 15:56:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287862#M22256</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2014-04-22T15:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Define a function in Tool Class of PYT</title>
      <link>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287863#M22257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are trying to reference it at the class level without using self which won't work. You need to pass self to the function so the class can reference it, declare it within another function, or reference it outside the class.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Apr 2014 16:03:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287863#M22257</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2014-04-22T16:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Define a function in Tool Class of PYT</title>
      <link>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287864#M22258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You are trying to reference it at the class level without using self which won't work. You need to pass self to the function so the class can reference it, declare it within another function, or reference it outside the class.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So do I just need to add self as the first parameter to the function like so?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
MyFunction(self, param1, param2, param3):
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Do stuff
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:54:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287864#M22258</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2021-12-11T13:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Define a function in Tool Class of PYT</title>
      <link>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287865#M22259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes that should allow you to reference it within the class using self.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Apr 2014 16:39:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287865#M22259</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2014-04-22T16:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Define a function in Tool Class of PYT</title>
      <link>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287866#M22260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Yes that should allow you to reference it within the class using self.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sweet. Thanks Mat!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Apr 2014 16:42:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287866#M22260</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2014-04-22T16:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Define a function in Tool Class of PYT</title>
      <link>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287867#M22261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So after I made the changes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
class Toolbox(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Toolbox Initialization Settings"""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.label = "My Very Own Toolbox"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.alias = MVO_tbx"

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List of the tools contained within the Toolbox
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.tools = [ToolClass]

class ToolClass(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Define the tool."""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.label = "MyTool"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.description = "No Description"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.canRunInBackground = True

&amp;nbsp;&amp;nbsp;&amp;nbsp; def getParameterInfo(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Establish the Parameters"""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Input Features Parameter
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; param0 = arcpy.Parameter(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; displayName="Features",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="in_Features",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datatype="GPFeatureLayer",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parameterType="Required",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; direction="Input")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; param0.filter.list = ["Point"]

&amp;nbsp;&amp;nbsp;&amp;nbsp; def isLicensed(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Set whether tool is licensed to execute."""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return True

&amp;nbsp;&amp;nbsp;&amp;nbsp; def updateParameters(self, parameters):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the values and properties of parameters before internal
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; validation is performed.&amp;nbsp; This method is called whenever a parameter
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; has been changed."""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return

&amp;nbsp;&amp;nbsp;&amp;nbsp; def updateMessages(self, parameters):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the messages created by internal validation for each tool
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parameter.&amp;nbsp; This method is called after internal validation."""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return

&amp;nbsp;&amp;nbsp;&amp;nbsp; def MyFunction(self, inFeatureLayer):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(inFeatureLayer,&amp;nbsp; "NEW_SELECTION", '"ID" = ' + "'123456'")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SiteList = list(r[0] for r in arcpy.da.SearchCursor(inFeatureLayer, "ID"))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return SiteList

&amp;nbsp;&amp;nbsp;&amp;nbsp; def execute(self, parameters, messages):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """The source code of the tool"""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inFeatureLayer = arcpy.parameters[0].valueAsText
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Result = MyFunction(inFeatureLayer) # Why doesn�??t this work???
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Do something with the result
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;When it gets to the method call in execute, I receive the error: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
TypeError: unbound method �??MyFunction�?� must be called with �??ToolClass�?� instance as first argument (got Layer instead)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried calling the method by referencing it via Class.method:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def execute(self, parameters, messages):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """The source code of the tool"""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inFeatureLayer = arcpy.parameters[0].valueAsText
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Result = ToolClass.MyFunction(inFeatureLayer) # Why doesn�??t this work???
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Do something with the result
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Posts on StackOverflow seem to indicate that I need to instantiate the Class Objectand then call the Tool from the instance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not really sure how to do that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:54:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287867#M22261</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2021-12-11T13:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Define a function in Tool Class of PYT</title>
      <link>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287868#M22262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need to reference it using self. ToolClass is the name of your class and &lt;/SPAN&gt;&lt;STRONG&gt;self &lt;/STRONG&gt;&lt;SPAN&gt;is how the class is referenced when you are within that class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; Result = self.MyFunction(inFeatureLayer)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think there is anything in the .pyt format that would prevent this functionality but I have not tested this myself.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 13:16:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287868#M22262</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2014-04-23T13:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Define a function in Tool Class of PYT</title>
      <link>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287869#M22263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You need to reference it using self. ToolClass is the name of your class and &lt;STRONG&gt;self &lt;/STRONG&gt;is how the class is referenced when you are within that class.&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt; Result = self.MyFunction(inFeatureLayer)&lt;/PRE&gt;&lt;BR /&gt;I don't think there is anything in the .pyt format that would prevent this functionality but I have not tested this myself.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I reached out to Chris Fox earlier this morning and that was the exact answer he gave me. Makes total sense, thanks for posting. I knew it was something simple!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 17:10:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287869#M22263</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2014-04-23T17:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Define a function in Tool Class of PYT</title>
      <link>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287870#M22264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;On a smilar vein, how do you do this within a arcpy.addin toolbar? (i.e. within a class?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried and tried and can't get it to work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You define the function outside the onClick(self) but within the class right? And then how would you call it from within onClick(self)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit- Never mind, got it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 21:23:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/define-a-function-in-tool-class-of-pyt/m-p/287870#M22264</guid>
      <dc:creator>TimBarnes</dc:creator>
      <dc:date>2014-04-23T21:23:51Z</dc:date>
    </item>
  </channel>
</rss>

