#NEWLINE# def __getitem__( self , item ) : #NEWLINE# #INDENT# '\n        Gets a layer according to its index or its name\n\n        :param item: layer index or name\n        :return: Layer object.\n        ' #NEWLINE# if isinstance ( item , int ) : #NEWLINE# #INDENT# return self . layers [ layer ] #NEWLINE# #UNINDENT# for layer in self . layers : #NEWLINE# #INDENT# if ( layer . layer_name == item . lower ( ) ) : #NEWLINE# #INDENT# return layer #NEWLINE# #UNINDENT# #UNINDENT# raise KeyError ( 'Layer does not exist in packet' )