I have a legacy python program which defined a module whose name conflict with a system module in the current python, what’s the easiest method to fix this? This module has been imported in many place, so it would be great if no need to change the the old python source.
Share
You could create a custom import routine using the
imp module. For example, here I’m importing a module namedstringwhich shadows the real string module:Output: