Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have the following code:

mxd["C1"] = arcpy.mapping.MapDocument(os.path.join(fRoot, filename))
mxd["C2"] = [arcpy.mapping.MapDocument(os.path.join(fRoot, filename))]

C1 creates a geoprocessing Map object

C2 creates a MapDocument object

What is the difference between them in terms of functionality and/or limitations?

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s30000000n000000

UPDATE: Still not really sure what the difference is but found out in order to run my program I required to have geoprocessing Map objects and not MapDocument objects.

Things like mxd.save(), and assigning the dataframe only seem to work with the geoprocessing object.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You're getting the same exact thing in both instances. Nothing to see here, move along.

When you print an object in Python, it runs the str operator on it*. str(MapDocument) says something like Geoprocessing Map Object or whatever. When you do str(list) it will use the repr operator on each item in it, so it will get something like [<arcpy.MapDocument object at 0x00000000>] where the <...> part is what repr returned. Both str and repr are simply string representations (with different implicit semantics) of the same thing, this object implements both and returns something slightly different for either.

*Note: As an implementation detail, in CPython it will actually go through the native tp_print method in most cases which is functionally the same thing.

share|improve this answer
    
Interesting -- I wonder why they decided to call it a "Geoprocessing Map Object" instead of a "Geoprocessing Map Document Object", since a map document has 1 or more maps (data frames). –  blah238 Sep 20 '12 at 21:50
1  
Because I didn't think it was a big deal when I wrote it? :) –  Jason Scheirer Sep 20 '12 at 21:52
    
Funny, got me wondering what a map object is called! See below. –  blah238 Sep 20 '12 at 22:00
    
Nice answer, I guess I was wrong in assuming it was analogous to the ArcObjects counterpart. I hope naming does turn into another ADF fiasco. –  Ragi Yaser Burhum Sep 21 '12 at 14:32
add comment

Not an answer, just an example of the output of str() and repr() given a MapDocument object:

>>> mxd = arcpy.mapping.MapDocument(r"c:\Program Files\ArcGIS\DeveloperKit10.0\Samples\data\BloomfieldTownship\BloomfieldTownship.mxd")
>>> repr(mxd)
'<MapDocument object at 0xde68d0[0x53fa520]>'
>>> str(mxd)
'<geoprocessing Map object object at 0x053FA520>'

And for the map (data frame) object:

>>> df = arcpy.mapping.ListDataFrames(mxd)[0]
>>> repr(df)
'<DataFrame object at 0x5420670[0x5434688]>'
>>> str(df)
'<geoprocessing Data Frame object object at 0x05434688>'
share|improve this answer
add comment

Your Answer

 
discard

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.