2

Possible Duplicate:
In Python, what does preceding a string literal with “r” mean?

I'm working through the Django tutorial on the DjangoProject.com website. I came to the part where I need to configure url routing by modifying the urls.py file.

Here's my question; what does the r before the '^admin/' in the first string argument in the line below mean?

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
)
Community
  • 1
  • 1
quakkels
  • 11,676
  • 24
  • 92
  • 149

2 Answers2

5

It is a raw python string literal; any \n or other character escape is not interpreted.

Since you often use the backslash in regular expressions (where they have their own meaning) it is common practice to use raw string literals for such expression definitions.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
0

It means to treat this string as a literal. Often times you see characters like '\' that need to be escaped, the use of 'r' prevents that from needing to be explicitly written.

Woot4Moo
  • 23,987
  • 16
  • 94
  • 151