Say, I have a dict
URLS = {'admin' : '/admin/(.*)'}
and if I do so
application = ([
(r(URLS['admin']), AdminPage)
], debug=True)
google app engine will raise an error
NameError: name 'r' is not defined
I really rea开发者_高级运维lly need to pass dictionary described in regexp to URL map for making my code more module.
What should I do to make it work?
thank you for your help!
The 'r' is a string prefix to escape some sequences for regular expression. It is not a function. http://docs.python.org/reference/lexical_analysis.html#string-literals
URLS = {'admin' : r'/admin/(.*)'}
application = webapp.WSGIApplication([
(URLS['admin'], AdminPage)
], debug=True)
The "webapp.WSGIApplication" will compile these strings to regex itself.
I believe re.compile
is what you are looking for.
精彩评论