FAQ

On 11 September 2015 at 02:30, Chris Angelico wrote:
On Fri, Sep 11, 2015 at 1:55 AM, Nick Coghlan wrote:
The second couldn't be handled the way virtualenv does things, but it
*could* be handled through a tool like vex which creates new subshells
and runs commands in those rather than altering the current shell:

$ python3
Python 3.4.2 (default, Jul 9 2015, 17:24:30)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import subprocess
subprocess.call(["vex", "nikola", "python"])
Python 2.7.10 (default, Jul 5 2015, 14:15:43)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
print("Hello virtual environment!")
Hello virtual environment!
Hmm. This looks like something that could confuse people no end. I
already see a lot of people use Ctrl-Z to get out of a program (often
because they've come from Windows, I think), and this would be yet
another way to get lost as to which of various Python environments
you're in. Is it safe to have Python exec to another process? That
way, there's no "outer" Python to be left behind, and it'd feel like a
transition rather than a nesting. ("Please note: Selecting a virtual
environment restarts Python.")

Using subprocess.call() to invoke vex was something I could do without
writing a single line of code outside the REPL. An actual PEP would
presumably propose something with a much nicer UX :)


Cheers,
Nick.


--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

People

Translate

site design / logo © 2017 Grokbase