title: How can I pickle a dynamically created nested class in python?
body: <p>I have a nested class:</p>
  <pre>
  class WidgetType(object):
      
      class FloatType(object):
          pass
      
      class TextType(object):
          pass
  </pre>    
  <p>.. and an object that refers the nested class type (not an instance of it) like this</p>
  <pre>
  class ObjectToPickle(object):
       def __init__(self):
           self.type = WidgetType.TextType
  </pre>
  <p>Trying to serialize an instance of the ObjectToPickle class results in:</p>
  <blockquote>
  <p><em>PicklingError: Can't pickle &lt;class
  'setmanager.app.site.widget_data_types.TextType'&gt;</em></p>
  </blockquote>
  <p>Is there a way to pickle nested classes in python?</p>