def NamedTuple(typename, fields):
 fields = [(n, t) for (n, t) in fields]
 cls = collections.namedtuple(typename, [n for (n, t) in fields])
 cls._field_types = dict(fields)
 try:
  cls.__module__ = sys._getframe(1).f_globals.get(u'__name__', u'__main__')
 except (AttributeError, ValueError):
  pass
 return cls

def NamedTuple ( typename , fields ) : fields = [ ( n , t ) for ( n , t ) in fields ] cls = collections . namedtuple ( typename , [ n for ( n , t ) in fields ] ) cls . _field_types = dict ( fields ) try : cls . __module__ = sys . _getframe ( 1 ) . f_globals . get ( u'__name__' , u'__main__' ) except ( AttributeError , ValueError ) : pass return cls
typed version of namedtuple .