Skip to content

Instantly share code, notes, and snippets.

@yuvipanda
Created March 11, 2014 09:51
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 yuvipanda/9482642 to your computer and use it in GitHub Desktop.
Save yuvipanda/9482642 to your computer and use it in GitHub Desktop.
class NamedVector(object):
def __init__(self, array, names):
for i in xrange(len(names)):
self.__dict__[names[i]] = array[i] if i < len(array) else None
f = NamedVector([1, 4], ("hi", "ho", "ee"))
print f.hi, f.ho, f.ee
f = NamedVector([1, 4, 99], ("hi", "ho", "ee"))
print f.hi, f.ho, f.ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment