How can I obtain pattern string from compiled regexp pattern in python?

python, regex

Solution

p.pattern

Read more about re module here: http://docs.python.org/library/re.html

Problem

I have some code like this one: ``` >>> import re >>> p = re.compile('my pattern') >>> print p _sre.SRE_Pattern object at 0x02274380 ``` Is it possible to get string `"my pattern"` from `p` variable?

Original source