Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a script to replace a layer datasource, and I'm getting an error I cannot figure out.

When I run the following code in a python window inside ArcMap, I get a "Runtime error : 'unicode' object is not callable"

import arcpy
mxd = arcpy.mapping.MapDocument ("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
     if lyr.supports("DATASOURCE"):
         if lyr.dataSource (r"N:\3_PLANNING\6_GIS\GIS Data\INDIANA GIS\Indiana_County.mdb\Boundaries\Indianacounty_shp"):
             lyr.replaceDataSource (r"N:\3_PLANNING\6_GIS\GIS Data\Indiana_County_Database_201201.gdb", "FILEGDB_WORKSPACE", r"N:\3_PLANNING\6_GIS\GIS Data\Indiana_County_Database_201201.gdb\Boundaries\County_Boundary")

Problem is, I'm not very good at python yet, and I'm not sure what the unicode object is that the error is referring to.

share|improve this question
Can you please post the full stack trace? Is this all the code? What are you using to create the python script? – Jamie Jan 10 '13 at 15:56
Not sure what you mean by full stack trace. Yes, it is all the code. I'm just using the python window in ArcGIS and IDLE. – Chris Jan 10 '13 at 17:56

Turns out the issue was:

if lyr.dataSource (r"N:\3_PLANNING\6_GIS\GIS Data\INDIANA GIS\Indiana_County.mdb\Boundaries\Indianacounty_shp"):

it should be:

if lyr.dataSource == "N:\3_PLANNING\6_GIS\GIS Data\INDIANA GIS\Indiana_County.mdb\Boundaries\Indianacounty_shp":
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.