While investigating Ruby I came across this to create a simple Struct-like class:
Person = Struct.new(:forname, :surname)
person1 = Person.new(\'John\', \'Do
As others have said, named tuples in Python 2.6/3.x. With older versions, I usually use the Stuff class:
class Stuff(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
john = Stuff(forename='John', surname='Doe')
This doesn't protect you from mispellings though. There's also a recipe for named tuples on ActiveState:
http://code.activestate.com/recipes/500261/