<?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>idea arcpy.env.workspace should accept a workspace object in Python Ideas</title>
    <link>https://community.esri.com/t5/python-ideas/arcpy-env-workspace-should-accept-a-workspace/idi-p/1690841</link>
    <description>&lt;P&gt;I was working on a tool the other day. It was something along the lines of :&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.env.workspace = arcpy.management.CreateFileGDB(r"C:\\Documents", "Example")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got an error&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;arcpy.env.workspace = arcpy.management.CreateFileGDB(fol, "Example")&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 564, in set_&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;self[env] = val&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;~~~~^^^^^&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 640, in __setitem__&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ret_ = setattr(self._gp, item, value)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;RuntimeError: Object: Error in accessing environment &amp;lt;workspace&amp;gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;However,&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = str(arcpy.management.CreateFileGDB(fol, "Example"))&lt;/P&gt;&lt;P&gt;works just fine.&lt;/P&gt;&lt;P&gt;CreateFileGDB returns a workspace object. It stands to reason arcpy.env.workspace should be able to consume it.&lt;/P&gt;&lt;P&gt;Please let arcpy.env.workspace take workspace objects.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Mar 2026 15:55:42 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2026-03-16T15:55:42Z</dc:date>
    <item>
      <title>arcpy.env.workspace should accept a workspace object</title>
      <link>https://community.esri.com/t5/python-ideas/arcpy-env-workspace-should-accept-a-workspace/idi-p/1690841</link>
      <description>&lt;P&gt;I was working on a tool the other day. It was something along the lines of :&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.env.workspace = arcpy.management.CreateFileGDB(r"C:\\Documents", "Example")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got an error&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;arcpy.env.workspace = arcpy.management.CreateFileGDB(fol, "Example")&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 564, in set_&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;self[env] = val&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;~~~~^^^^^&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 640, in __setitem__&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ret_ = setattr(self._gp, item, value)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;RuntimeError: Object: Error in accessing environment &amp;lt;workspace&amp;gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;However,&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = str(arcpy.management.CreateFileGDB(fol, "Example"))&lt;/P&gt;&lt;P&gt;works just fine.&lt;/P&gt;&lt;P&gt;CreateFileGDB returns a workspace object. It stands to reason arcpy.env.workspace should be able to consume it.&lt;/P&gt;&lt;P&gt;Please let arcpy.env.workspace take workspace objects.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2026 15:55:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/arcpy-env-workspace-should-accept-a-workspace/idi-p/1690841</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2026-03-16T15:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.env.workspace should accept a workspace object</title>
      <link>https://community.esri.com/t5/python-ideas/arcpy-env-workspace-should-accept-a-workspace/idc-p/1690978#M572</link>
      <description>&lt;P&gt;Workspace objects should also just kinda behave like Path objects. Keeping track of which functions require a concrete class input and which ones need some form of string is a pain. If the concretes could behave like a string when used as an input (e.g. implement __str__ and __fspath__), the consuming function would just need to call arg = str(arg) and the conversion is made.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2026 12:24:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/arcpy-env-workspace-should-accept-a-workspace/idc-p/1690978#M572</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2026-03-17T12:24:29Z</dc:date>
    </item>
  </channel>
</rss>

