<?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: Finding script location... dynamically in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/finding-script-location-dynamically/m-p/636174#M49506</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use &lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;os.path.dirname(sys.argv[0])&lt;/PRE&gt;&lt;SPAN&gt; or &lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;os.path.dirname(__file__)&lt;/PRE&gt;&lt;SPAN&gt; to get the directory&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Feb 2012 15:53:44 GMT</pubDate>
    <dc:creator>JasonScheirer</dc:creator>
    <dc:date>2012-02-06T15:53:44Z</dc:date>
    <item>
      <title>Finding script location... dynamically</title>
      <link>https://community.esri.com/t5/python-questions/finding-script-location-dynamically/m-p/636173#M49505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Should be a simple question... but those can be the hardest. I have created a script that uses ESRI's arcpy site package and it functions properly in a stand-alone environment. I am now trying to integrate this script into a toolbox to be run within an open ArcMap session and I am having trouble. In integrating this script I am using the tool structure that ESRI suggests... &lt;/SPAN&gt;&lt;A href="http://goo.gl/eesrV"&gt;http://goo.gl/eesrV&lt;/A&gt;&lt;SPAN&gt; . The script I have created has information in the 'ToolData' folder that I need to access to run the script. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the question is how do I locate the script's directory dynamically when running it in an open ArcMap session?&amp;nbsp; In my stand-alone script I use 'os.getcwd()'; this works because it returns the proper location of the script and I then know the structure around it. Whereas when incorporated as a script in a tool box and run within an ArcMap session 'os.getcwd()' returns the directory of the map document while the toolbox, script, and tool data are located where ever the user installed them and my script can't find this structure. Thanks for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2012 15:03:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-script-location-dynamically/m-p/636173#M49505</guid>
      <dc:creator>C__JustinMayers</dc:creator>
      <dc:date>2012-02-06T15:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Finding script location... dynamically</title>
      <link>https://community.esri.com/t5/python-questions/finding-script-location-dynamically/m-p/636174#M49506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use &lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;os.path.dirname(sys.argv[0])&lt;/PRE&gt;&lt;SPAN&gt; or &lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;os.path.dirname(__file__)&lt;/PRE&gt;&lt;SPAN&gt; to get the directory&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2012 15:53:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-script-location-dynamically/m-p/636174#M49506</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2012-02-06T15:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Finding script location... dynamically</title>
      <link>https://community.esri.com/t5/python-questions/finding-script-location-dynamically/m-p/636175#M49507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;double-posted here for further commentary&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://gis.stackexchange.com/questions/19860/finding-script-location-dynamically"&gt;http://gis.stackexchange.com/questions/19860/finding-script-location-dynamically&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2012 16:19:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-script-location-dynamically/m-p/636175#M49507</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2012-02-06T16:19:07Z</dc:date>
    </item>
  </channel>
</rss>

