The functools module refers to reduce , which is defined in _functools . Meanwhile, _functools refers to partial , which is defined in functools
I ran into this problem while trying to create a copy of the namespace for correcting monkeys. But in my case, I need both old and monkey-fixed functionality, so you need a copy. Any suggestion, what a good way for circular dependencies like this?
Using Python 2.7.10
Some source code for the request
def _get_dependent_modules(m): """Return set of all modules defining symbols in given module.""" modules = set() for symbol_name, symbol in m.__dict__.items(): if hasattr(symbol, '__module__'): if symbol.__module__ in sys.modules: print "Symbol %s, defined in %s" % (symbol_name, symbol.__module__) modules.add(sys.modules[symbol.__module__]) else: print "Cant find module for %s" %(symbol) return modules _get_dependent_modules(functools) Symbol wraps, defined in functools Symbol partial, defined in functools Symbol update_wrapper, defined in functools Symbol total_ordering, defined in functools Symbol reduce, defined in _functools Symbol cmp_to_key, defined in functools _get_dependent_modules(sys.modules["_functools"]) Symbol partial, defined in functools Symbol reduce, defined in _functools
source share