On Fri, 8 Apr 2022 at 10:27, Malthe <mborch@gmail.com> wrote:
On Fri, 8 Apr 2022 at 08:51, Paul Moore <p.f.moore@gmail.com> wrote:
Are you exaggerating for effect here or would this *actually* just expand to
from datetime import datetime default_args = { "start_date": datetime(...) }
Yes – and of course that is just a snippet, an actual complete script will have lots of such imports.
The point is that in a scripting situation (especially one in which you have many small scripts) the top-level import requirement for simple imports like `datetime` becomes rather verbose.
But Python's origin is in scripting situations, and explicit imports for scripts has always been both the normal approach, and one of Python's *strengths* ("Explicit is better than implicit"). Arguing that explicit imports are a bad thing in (general) scripts is arguing against decades of history and experience. If there's a reason why *your specific context* would benefit from an abbreviated form, you need to present it. But arguing that explicit imports are too verbose for all cases of scripting isn't going to fly, frankly. Paul