<s> from collections import OrderedDict <EOL> import copy <EOL> class DefaultOrderedDict ( OrderedDict ) : <EOL> __slots__ = '<STR_LIT>' , <EOL> def __init__ ( self , default_factory = None , * a , ** kw ) : <EOL> if default_factory is not None and not callable ( default_factory ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> OrderedDict . __init__ ( self , * a , ** kw ) <EOL> self . default_factory = default_factory <EOL> def __missing__ ( self , key ) : <EOL> if self . default_factory is None : <EOL> raise KeyError ( key ) <EOL> self [ key ] = value = self . default_factory ( ) <EOL> return value <EOL> def __reduce__ ( self ) : <EOL> if self . default_factory is None : <EOL> args = tuple ( ) <EOL> else : <EOL> args = self . default_factory , <EOL> return type ( self ) , args , None , None , iter ( self . items ( ) ) <EOL> def copy ( self ) : <EOL> return self . __copy__ ( ) <EOL> def __copy__ ( self ) : <EOL> return type ( self ) ( self . default_factory , self ) <EOL> def __deepcopy__ ( self , memo ) : <EOL> return self . __class__ ( self . default_factory , copy . deepcopy ( list ( self . items ( ) ) ) ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . default_factory , <EOL> OrderedDict . __repr__ ( self ) [ <NUM_LIT> : - <NUM_LIT:1> ] ) </s>
