<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scoped_to(self, scope):
 """ Context manager to switch scopes. """

        previous_scope = self.__factory__.current_scope
        try:
            self.__factory__.current_scope = scope
            yield
        finally:
            self.__factory__.current_scope = previous_scope