def as_dict ( self ) : attrs = vars ( self ) return { key : attrs [ key ] for key in attrs if not key . startswith ( '_' ) }
python all attributes for an object
Package up the public attributes as a dict .
def as_dict(self):
        """Package up the public attributes as a dict."""
        attrs = vars(self)
        return {key: attrs[key] for key in attrs if not key.startswith('_')}