The components of the URLs of the Django app I'm working on are very 'pluggable', and different combinations of them get used in various urlpatterns, so our urls.py looks something like:
rev = r'(/R\.(?P<rev>\d+))?'
repo_type= r'^(?P<repo_type>svn|hg)/'
path = r'/dir/(?P<path>.*)$'
# etc.
urlpatterns = patterns('',
(repo_type_param + r'view-source' + opt_rev_param + path_param, view_source),
(repo_type_param + r'history' + path_param, history),
(repo_type_param + r'revision' + opt_rev_param + r'/$', revision),
) #etc.
Which seems like a nice way to keep things clean. However, I found I kept getting NoReverseMatch errors when I tried to reverse any of the views pointed to by the urlpatterns. After a lot of tinkering, I found that using the full raw string in the pattern, rather than concatenating the substrings, fixed the problem.
So, is it really necessary to use only raw strings in urlpatterns? I couldn't find this documented anywhere. Bug or feature? Having to copy and paste regex patterns that get used repeatedly seems like a violation of DRY.