[Python-ideas] Syntax to import modules before running command from the command line

Paul Moore p.f.moore at gmail.com
Wed Jan 10 03:30:01 EST 2018


On 10 January 2018 at 02:39, Nick Coghlan <ncoghlan at gmail.com> wrote:
> For the coverage.py use case, an environment-based solution is also
> genuinely helpful, since you typically can't modify subprocess
> invocations just because the software is being tested. At the moment,
> there are approaches that rely on using either `sitecustomize` or
> `*.pth` files, but being able to write `PYTHONRUNFIRST="import
> coverage; coverage.process_startup()"` would be a fair bit clearer
> about what was actually going on.

It's worth remembering that Windows doesn't have the equivalent of the
Unix "VAR=xxx prog arg arg" syntax for one-time setting of an
environment variable, so environment variable based solutions are
strictly less useful than command line arguments. That's one reason I
prefer -C over PYTHONRUNFIRST.

Paul


More information about the Python-ideas mailing list