#NEWLINE# def namedtupledict( name , fields ) : #NEWLINE# #INDENT# cls = namedtuple ( name , fields ) #NEWLINE# def __getitem__( self , item ) : #NEWLINE# #INDENT# if isinstance ( item , basestring ) : #NEWLINE# #INDENT# warnings . warn ( 'namedtuple fields should be accessed as attributes' , DeprecationWarning ) #NEWLINE# return getattr ( self , item ) #NEWLINE# #UNINDENT# return cls . __getitem__ ( self , item ) #NEWLINE# #UNINDENT# def get( self , item , default = None ) : #NEWLINE# #INDENT# warnings . warn ( 'namedtuple fields should be accessed as attributes' , DeprecationWarning ) #NEWLINE# return getattr ( self , item , default ) #NEWLINE# #UNINDENT# return type ( name , ( cls , ) , { #NEWLINE# #INDENT# '__getitem__' : __getitem__ , #NEWLINE# 'get' : fields , #NEWLINE# #UNINDENT# } )