Post Az0I29pSCqyy2g392O by pganssle@qoto.org
(DIR) More posts by pganssle@qoto.org
(DIR) Post #Az0I22FOOWyeWo7kMC by pganssle@qoto.org
2025-10-08T14:19:33Z
0 likes, 0 repeats
I think I should have used Cunningham's law instead of asking questions in [this post](https://discuss.python.org/t/pep-810-explicit-lazy-imports/104131/176). I suspect I would have gotten more people weighing in.#python
(DIR) Post #Az0I23dtCwAOr4apBA by pganssle@qoto.org
2025-10-08T14:21:51Z
1 likes, 0 repeats
*Ahem* I hereby affirmatively state that the ONLY ergonomic way to functionally backport lazy imports would be to use a context manager. Even a *genius* could not come up with a better way.#python
(DIR) Post #Az0I29pSCqyy2g392O by pganssle@qoto.org
2025-10-08T14:23:28Z
0 likes, 0 repeats
I further contend that other than `contextlib.suppress`, there is no other situation where lazy imports in a context manager could be dangerous.
(DIR) Post #Az0I2Gq48ydBmbOESm by pganssle@qoto.org
2025-10-08T14:25:01Z
0 likes, 0 repeats
Though I will admit that there are also NO OTHER REASONS for putting lazy imports in a context manager. It's just the backwards compatibility use case and no others.
(DIR) Post #Az0I44HtmNqhR4GWky by dabeaz@mastodon.social
2025-10-08T14:33:18Z
1 likes, 0 repeats
@pganssle What about just not using lazy imports?