2

I just noticed that in the arcpy module (Esri) there's a sys sub-module. Does anyone know what the difference is in using one or the other? I've been looking around and can't find anyone who uses arcpy.sys, so why would it be there?

edit: I wasn't clear, but arcpy.sys seems to be exactly the same as the python built-in sys module.

7

arcpy.sys==sys

arcpy imports the builtin sys module which is why it shows up in the arcpy namespace. Have a look at the arcpy/__init__.py code. It also imports other standard modules, such as os, glob,etc... which are then available in the arcpy namespace.

Try this in your python interpreter:

>>> import arcpy,sys,os
>>> print sys
<module 'sys' (built-in)>
>>> print arcpy.sys
<module 'sys' (built-in)>
>>> print sys==arcpy.sys
True
>>> print os==arcpy.os
True
| improve this answer | |
3

That module really is the core sys module and not actually related to Arcpy:

>D:\Python27\ArcGIS10.1\python.exe
>>> import arcpy.sys
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named sys
>>> import arcpy
>>> import sys
>>>

Really, Arcpy is just ESRI's name for geoprocessing tools that can be accessed via Python.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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