def _deprecated_getitem_method(name, attrs):
 attrs = frozenset(attrs)
 msg = "'{name}[{attr!r}]' is deprecated, please use '{name}.{attr}' instead"
 def __getitem__(self, key):
  '``__getitem__`` is deprecated, please use attribute access instead.\n        '
  warn(msg.format(name=name, attr=key), DeprecationWarning, stacklevel=2)
  if (key in attrs):
   return self.__dict__[key]
  raise KeyError(key)
 return __getitem__

def _deprecated_getitem_method ( name , attrs ) : attrs = frozenset ( attrs ) msg = "'{name}[{attr!r}]' is deprecated, please use '{name}.{attr}' instead" def __getitem__ ( self , key ) : warn ( msg . format ( name = name , attr = key ) , DeprecationWarning , stacklevel = 2 ) if ( key in attrs ) : return self . __dict__ [ key ] raise KeyError ( key ) return __getitem__
create a deprecated __getitem__ method that tells users to use getattr instead .