def localcontext(ctx=None):
 if (ctx is None):
  ctx = getcontext()
 return _ContextManager(ctx)

def localcontext ( ctx = None ) : if ( ctx is None ) : ctx = getcontext ( ) return _ContextManager ( ctx )
return a context manager for a copy of the supplied context uses a copy of the current context if no context is specified the returned context manager creates a local decimal context in a with statement: def sin(x): with localcontext() as ctx: ctx .