Last active
July 25, 2016 16:03
-
-
Save sdshlanta/8628427449039214611aa2dfec03cf32 to your computer and use it in GitHub Desktop.
Because I got tired of writing self.x all the time when making data classes
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
class dataClassTemplate(): | |
_fields = [] | |
def __init__(self, *args): | |
for name, val in zip(self.__class__.fields, args) | |
setattr(self, name, val) | |
class Record(dataClassTemplate): | |
_fields = ["owner", "systemName"] #put the names of the feilds in here | |
r = Record("Hello","world") | |
r.owner #hello | |
r.systemName #world | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment