Add clone() method to Field to get clean copies of it.

This commit is contained in:
Andrew Godwin 2013-12-04 13:55:45 +00:00
parent ab587fa51a
commit df800b1609
1 changed files with 8 additions and 0 deletions

View File

@ -240,6 +240,14 @@ class Field(object):
keywords,
)
def clone(self):
"""
Uses deconstruct() to clone a new copy of this Field.
Will not preserve any class attachments/attribute names.
"""
name, path, args, kwargs = self.deconstruct()
return self.__class__(*args, **kwargs)
def __eq__(self, other):
# Needed for @total_ordering
if isinstance(other, Field):