Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Matt Wheeler Newsgroups: comp.lang.python Subject: Re: Guido on python3 for beginners Date: Thu, 18 Feb 2016 16:44:36 +0000 Lines: 30 Message-ID: References: <48762040-a7e0-434c-92e8-8a0969210e5b@googlegroups.com> <5d31dd14-1a60-4f80-8889-d0616f404c70@googlegroups.com> <4e902c58-3370-4adf-905d-74630a6eea90@googlegroups.com> <60036746-78f7-4f05-a6d8-04e88b09c00f@googlegroups.com> <032f0f66-34df-4325-98e0-1127025d2a94@googlegroups.com> <31a618b2-a407-4723-9a4f-9b756fc93b0b@googlegroups.com> <0a920e92-5d31-4866-815b-cae7e201e4d8@googlegroups.com> <56c568f2$0$2832$c3e8da3$76491128@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de gZPyq4S1BswsgpLbYAU7rw303sE3L42kn/jLMOo5wXPA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'enabling': 0.05; 'bash': 0.07; 'cc:addr:python-list': 0.09; 'returns,': 0.09; 'python': 0.10; 'applies': 0.15; 'thu,': 0.15; '&&': 0.16; '(also': 0.16; "(i'm": 0.16; '2016': 0.16; 'bash,': 0.16; 'deactivate': 0.16; 'echo': 0.16; 'fluent': 0.16; 'magic': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:python3': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'email addr:gmail.com>': 0.18; 'shell': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'users,': 0.22; 'bit': 0.23; 'feb': 0.23; 'previously': 0.24; 'header:In-Reply- To:1': 0.24; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'idea': 0.28; 'accidentally': 0.29; 'approved,': 0.29; 'comments': 0.30; "can't": 0.32; 'run': 0.33; 'source': 0.33; 'editor': 0.34; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'activate': 0.35; 'received:74.125.82': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'environment.': 0.37; 'stuff': 0.38; 'skip:p 20': 0.38; 'does': 0.39; 'your': 0.60; 'more': 0.63; 'soon': 0.65; 'skip:$ 10': 0.67; '11:07': 0.84; 'from:addr:m': 0.84; 'received:74.125.82.47': 0.84; 'way...': 0.84; 'confirms': 0.95 X-Virus-Scanned: Debian amavisd-new at membrane.funkyhat.net X-Gm-Message-State: AG10YORvdww7Ghf8hMT7GwymKgiUVSsje8WpYuzdJUfsOVV12fYrifoR/bebYIhPk/ajgW+L9gedO0QdAxaeZQ== X-Received: by 10.28.130.205 with SMTP id e196mr4536353wmd.34.1455813895659; Thu, 18 Feb 2016 08:44:55 -0800 (PST) In-Reply-To: X-Gmail-Original-Message-ID: X-Content-Filtered-By: Mailman/MimeDel 2.1.21rc2 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103135 On Thu, 18 Feb 2016 11:07 Chris Angelico wrote: > By the way... For bash users, adding this to .bashrc may make venvs a > bit easier to keep straight: > > checkdir() { > [ -n "$VIRTUAL_ENV" ] && ! [[ `pwd` =~ `dirname $VIRTUAL_ENV`* ]] > && echo Deactivating venv $VIRTUAL_ENV... && deactivate > [ -z "$VIRTUAL_ENV" -a -d env ] && echo Activating venv > `pwd`/env... && source env/bin/activate > } > PROMPT_COMMAND=checkdir > > (I'm more fluent in Python than in bash, so this is a bit ugly.) > > As soon as you change out of the directory that contains your venv, > it'll be deactivated, so you can't accidentally run stuff in the > "wrong" environment. And as soon as you change into a directory that > contains an 'env' subdir, it'll activate it. (Also applies on first > creation; as soon as "python3 -m venv env" returns, this will activate > the env.) > This is a bad idea for the same reason enabling all magic comments in your editor is a bad idea. (rvm does this but confirms that the rvmrc it's about to activate is one that you've previously approved, I wouldn't want to try to write a shell function that did that though :)). >