re.compile versus r''

Fredrik Lundh fredrik at
Thu Aug 28 21:29:57 CEST 2008

Terrence Brannon wrote:

> Hello, I'm using a tool (PLY) which apparently expects the tokens to
> be created using r''
> But because one token is a rather complex regular expression, I want
> to create the regular expression programmatically.
> How can I generate a string and then create something of the same type
> that the r'' function does?

r'' is an alternative syntax for string literals that affects how escape 
sequences are interpreted; there's no separate string type for strings 
created by this syntax.


More information about the Python-list mailing list