Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

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

what is os.sep and when should i use os.sep while scripting for arcgis ? for example in below code i don't understand why should i use os.sep .

import arcpy
from arcpy import env
import os

# Set the workspace for the ListFeatureClass function
env.workspace = "c:/base"

# Use the ListFeatureClasses function to return a list of 
#  all shapefiles.
fcList = arcpy.ListFeatureClasses()

# Copy shapefiles to a file geodatabase
for fc in fcList:
  arcpy.Copy_management(fc, "d:/base/output.gdb" + os.sep + fc.rstrip(".shp"))


share|improve this question
Please note that this question is one of those "borderline" ones that is of (at best) marginal interest on a GIS site, because (a) it clearly has nothing special to do with the GIS program you're working with and (b) an obvious search on the Web immediately turns up an answer (Google "os.sep" for instance). We're letting it stand because it has been answered and you're a relatively new user, but future questions meeting these criteria will be closed or migrated to a purely programming site. – whuber May 19 '11 at 15:23

Just use os.path.join(), noting the caveat for Windows at It takes care of the os.sep for you and makes your code more portable (not that ArcPy is portable, but in general).

for fc in fcList:
        fc, os.path.join("d:/base/output.gdb", fc.rstrip(".shp")))
share|improve this answer
This is a good point. Using os.path.join() is a better method for building paths. – OptimizePrime May 19 '11 at 15:55

os.sep is the (or a most common) pathname separator ('/' or ':' or '\')

share|improve this answer
thank you so much – wetland May 19 '11 at 13:52
@GIS A constructive way to express your appreciation is to accept one of these answers. If you're not sure how to do this, please read the FAQ. – whuber May 19 '11 at 15:20

try this...

In your favourite python environment type:

import os
print os.sep

Your output will be '\'or '/' depending on the operating system you're using.

@artwork21's answer is more complete ;) and beat me to the punch line!

share|improve this answer
thank you so much – wetland May 19 '11 at 13:52

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.