daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Oct 19th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. class MapDict(object):
  3.     '''A simple object-generator. Like a named-tuple.'''
  4.     def __init__(self, map, *args):
  5.         self.map = map
  6.         for index in range(self.map):
  7.             setattr(self, key[index], args[index])
  8.     def __str__(self):
  9.         return '\n'.join(['%s = "%s"' % (key, getattr(self, key))
  10.                           for key in self.map])
  11.  
  12. class MapObject(object):
  13.     '''Given a list and an object, copy those attributes to self'''
  14.     def __init__(self, obj):
  15.         self.map = obj.map
  16.         for key in self.map:
  17.             setattr(self, key, getattr(obj, key))
  18.     def __str__(self):
  19.         return '\n'.join(['%s = "%s"' % (key, getattr(self, key))
  20.                           for key in self.map])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top