title: TypeError: cannot deepcopy this pattern object
body: <p>Trying to understand this error in my "Variable" class. </p>
  
  <p>I was hoping to store a sre.SRE_Pattern  in my "Variable" class. I just started copying the Variable class and noticed that it was causing all my Variable class instances to change. I now understand that I need to deepcopy this class, but now I run into "TypeError: cannot deepcopy this pattern object". Sure, I can store the pattern as a text string but the rest of my code already expects a compiled pattern! What would be the best way to copy my Variable class with a pattern object? </p>
  
  <pre><code>import re
  from copy import deepcopy
  
  class VariableWithRE(object):
      "general variable class"
      def __init__(self,name,regexTarget,type):
          self.name = name
          self.regexTarget = re.compile(regexTarget, re.U|re.M) 
          self.type = type 
  
  class VariableWithoutRE(object):
      "general variable class"
      def __init__(self,name,regexTarget,type):
          self.name = name
          self.regexTarget = regexTarget
          self.type = type 
  
  if __name__ == "__main__":
  
      myVariable = VariableWithoutRE("myName","myRegexSearch","myType")
      myVariableCopy = deepcopy(myVariable)
  
      myVariable = VariableWithRE("myName","myRegexSearch","myType")
      myVariableCopy = deepcopy(myVariable)
  </code></pre>