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

2018-01-10 Thread Nick Coghlan
On 10 January 2018 at 18:30, Paul Moore wrote: > On 10 January 2018 at 02:39, Nick Coghlan 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 t

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

2018-01-10 Thread Paul Moore
On 10 January 2018 at 02:39, Nick Coghlan 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

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

2018-01-09 Thread Nick Coghlan
On 10 January 2018 at 07:54, Barry Warsaw wrote: > Steve Barnes wrote: >> Currently invoking `python -c "some;separated;set of commands;"` will, >> if you need to use any library functions, require one or more import >> somelib; sections in the execution string. This results in rather >> complex "

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

2018-01-09 Thread Ivan Pozdeev via Python-ideas
On 10.01.2018 0:54, Barry Warsaw wrote: Steve Barnes wrote: Currently invoking `python -c "some;separated;set of commands;"` will, if you need to use any library functions, require one or more import somelib; sections in the execution string. This results in rather complex "one liners". On the

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

2018-01-09 Thread Barry Warsaw
Steve Barnes wrote: > Currently invoking `python -c "some;separated;set of commands;"` will, > if you need to use any library functions, require one or more import > somelib; sections in the execution string. This results in rather > complex "one liners". > > On the other hand `python -m someli

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

2018-01-05 Thread Paul Moore
On 5 January 2018 at 08:12, Nick Coghlan wrote: > However, the issue then is that "python -M numpy" would just be a less > flexible alternative to a command like "python -C 'import numpy as > np'". For quick one-liners don't underestimate the value of avoiding punctuation: # No punctuation a

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

2018-01-05 Thread Nick Coghlan
On 5 January 2018 at 16:28, Steve Barnes wrote: > Currently invoking `python -c "some;separated;set of commands;"` will, > if you need to use any library functions, require one or more import > somelib; sections in the execution string. This results in rather > complex "one liners". > > On the oth

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

2018-01-04 Thread Wes Turner
An implicit print() would be convenient, too. On Friday, January 5, 2018, Wes Turner wrote: > Could it just check if -c and -m are both set? > That way there'd be no need for -p or -M. > > (I have an -m switch in pyline which does exactly this. It makes > copying and pasting less convenient; bu

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

2018-01-04 Thread Wes Turner
Could it just check if -c and -m are both set? That way there'd be no need for -p or -M. (I have an -m switch in pyline which does exactly this. It makes copying and pasting less convenient; but does save having to type 'import module;’ for one liners) On Friday, January 5, 2018, Steve Barnes w

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

2018-01-04 Thread Steve Barnes
Currently invoking `python -c "some;separated;set of commands;"` will, if you need to use any library functions, require one or more import somelib; sections in the execution string. This results in rather complex "one liners". On the other hand `python -m somelib` will load somelib and attempt