On Wed, Oct 30, 2019 at 12:54:13AM +0100, Richard Vogel wrote: > However, I don't see where > > > # Support many different versions of Python, or old versions > > # of the module, or drop-in replacement of the module. > > try: > > from module import name > > except ImportError: > > from fallback_module import spam as name > > might change a actual thing. > > Case 1: Lets say "module" does not exist -> both fail
When you say "both", you mean under the current behaviour, versus the proposed behaviour? And by "fail", you mean import from the fallback module? If so, then you are correct, there is no change between the status quo and the proposed behaviour for this scenario. > Case 2: Exactly one "module" exists but it does not contain "name" -> > both fail Again, no change in the status quo. > Case 3: Multiple "module" exist. At least one having "name" inside This is the scenario with a possible change in behaviour. To make it clear, let's suppose we have two modules called "spam.py", which I will tag as spam#1 and spam#2 (the tags #1 and #2 are not part of the file name, just listed to aid understanding). - spam#1 comes first in the path, and does not include "name"; - spam#2 comes second in the path, and does include "name". The status quo is that importing "name" from spam#1 fails and so the fallback version is loaded. But under the proposed change in behaviour, importing "name" from spam#1 fails, but instead of loading the fallback version, "name" from spam#2 is loaded instead. That's a change in behaviour. It could be an unwelcome one: just because both files are called "spam" doesn't mean that they are functionally equivalent. spam.name (from file #2) may be buggy, broken, obsolete, experimental, or do something completely unexpected. At the very least, it means that as the developer, there are two cases I am aware of and have tested: - load "name" from spam#1 - load fallback but there's a third, non-obvious scenario I may have forgotten or be unaware of: - load "name" from spam#2 and consequently have never tested. The point is not that the proposed behaviour is *necessarily* bad in this scenario, but that it is a change in behaviour. -- Steven _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/YOR72TIX2QWEIXUSFI545XINTVBXFOHD/ Code of Conduct: http://python.org/psf/codeofconduct/
