Last active
July 16, 2017 21:31
-
-
Save matyasfodor/16f1fb62ab7a8b6f799ad048bd4ca452 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def record_factory(cls_name, field_names): | |
# ... | |
def _asdict(self): | |
return {k: getattr(self, k) for k in self.__slots__} | |
cls_attrs = dict(__slots__ = field_names, | |
__init__ = __init__, | |
__iter__ = __iter__, | |
__repr__ = __repr__, | |
__hash__ = __hash__, | |
__eq__ = __eq__, | |
_asdict = _asdict) | |
return type(cls_name, (object,), cls_attrs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment