≈ the.bay.news

Lazy imports: how to use them in a CLI that supports <=3.15?

Discussions on Python.org
Lazy imports: how to use them in a CLI that supports <=3.15?
I maintain a CLI tool that supports Python 3.11 through 3.15 and I’m interested in implementing the new lazy import feature. How do I go about updating the workaround pattern, which uses a local import in the function call? import click @click.command() @click.argument("size", type=int, default=5) def cli(size): # workaround local import import numpy as np data = np.arange(size) click.echo(f"Generated array: {data}") if __name__ == "__main__": cli() Per the docs, for ...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.