Skip to content

Instantly share code, notes, and snippets.

@sdshlanta
Last active July 25, 2016 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdshlanta/8628427449039214611aa2dfec03cf32 to your computer and use it in GitHub Desktop.
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
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