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

I want to calculate a field, this is my working example in VB:

"C:\Users\Admin\Desktop\Data\" & !Work! & "\1000_\" & !Data! & ".pdf"

I'm slowly changing all my scripts to Python, how would I write this in Python?

got it:



share|improve this question
I suggest you post your edit ("got it: ...") as an answer, then accept either your answer or Clickinaway's. That way future readers with the same problem will quickly see how to solve it. – user3461 Apr 12 '13 at 14:37
I tried, wasn't able to answer it :/ – GEOGEO Apr 18 '13 at 10:30
up vote 4 down vote accepted

You could also use 'r' before your path reference OR use '/' to avoid the need for '\'

For example: r"C:\Users\Admin\Desktop\Data\"



Programming languages, such as Python, treat a backslash () as an escape character. For instance, \n represents a line feed, and \t represents a tab. When specifying a path, a forward slash (/) can be used in place of a backslash. Two backslashes can be used instead of one to avoid a syntax error. A string literal can also be used by placing the letter r before a string containing a backslash so it is interpreted correctly.

Setting paths to data in Python

share|improve this answer
r"C:\Users\Admin\Desktop\Data\" raises a SyntaxError, so it actually needs to be r"C:\Users\Admin\Desktop\Data\"" – Mike T Nov 25 '13 at 11:59

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.