Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Guido on python3 for beginners Date: Thu, 18 Feb 2016 22:07:05 +1100 Lines: 44 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 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de YF+Ipyc8snKndl1lrp6kMA4hsQ67MPlhBdmlNl+Y74yw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'root': 0.04; 'binary': 0.05; 'python3': 0.05; 'bash': 0.07; 'interpreter.': 0.07; 'cc:addr:python-list': 0.09; 'scripts': 0.09; '"python"': 0.09; 'beginners': 0.09; 'returns,': 0.09; 'python': 0.10; 'exception': 0.13; 'applies': 0.15; 'thu,': 0.15; '(also': 0.16; "(i'm": 0.16; '2016': 0.16; 'bash,': 0.16; 'deactivate': 0.16; 'echo': 0.16; 'first:': 0.16; 'fluent': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'privileges.': 0.16; 'py3': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:python3': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'board.': 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; 'consistent': 0.23; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'about.': 0.29; 'accidentally': 0.29; 'raise': 0.29; 'asked': 0.29; 'code': 0.30; "i'd": 0.31; 'probably': 0.31; 'another': 0.32; "can't": 0.32; 'run': 0.33; 'source': 0.33; 'environment,': 0.33; 'suddenly': 0.33; 'surprised': 0.33; 'that,': 0.34; 'received:google.com': 0.35; 'activate': 0.35; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'agree': 0.37; 'environment.': 0.37; 'starting': 0.37; 'things': 0.38; 'virtual': 0.38; 'received:209': 0.38; 'stuff': 0.38; 'skip:p 20': 0.38; 'files': 0.38; 'test': 0.39; 'where': 0.40; 'your': 0.60; 'side': 0.62; 'more': 0.63; 'personal': 0.63; 'soon': 0.65; 'skip:$ 10': 0.67; 'teaching': 0.69; 'feeling': 0.72; 'chrisa': 0.84; 'confusing': 0.84; 'pip': 0.84; 'way...': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=s7rBdQGsAlm7emmeloUBlz2nTzyAO3LS8az8+yd3PJc=; b=aYNwaS3vlIdvr7EDvFN2vSHhYhm1FZhesrPUJe8moZeTGaIweggxOEM70y5U3xJP/x 7aTBsLBmGGsoujKEn7rF+9Wc9xZx7Wfut9iuG7D8WC3uiQi6jUOA2vxfoP1J0hnSLMuq C3li5UQLI7SUHQ50zGFPdf7adjqMu14LPA4z0q1Gov2U5d9VMRfI/Vg2yzZysEBOVtvd ooRj+DZFSGPbRWwz6uhqPhSNgAc5bFhJUZ8exsfNtgAcImhKeL5PcT8SlUAKvcBryRrx 6Y2gG6hLjh9qDPicF7lh0LPbWG1p6yD6wbNc5JdBlUkbrZ47Jg2GL0eYqXKvjekVyhhU 6u2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type:content-transfer-encoding; bh=s7rBdQGsAlm7emmeloUBlz2nTzyAO3LS8az8+yd3PJc=; b=VTZoJie21MS9dovBVil9t3DcAVxBctmRFlpX+SS/ScMX0aNmtUVlwMK8xS9DEjQmgt yCa6iY1NG4d1PzEvXgHD3DSPLrP6fQQa8cmIxyyNoKUplPUEqM35Fhkb0WQYUNC5ytSt usHOYEpJJ3b4rMcuJzjEQRvxnU0rxfUyez6WseeNesRZKKKymCwI5Hb78CDqYi50WuDQ +AEV8H9Q2qjdGPmeGUa9OUKTNqZpyJqxbT/tpoS6258Ayf7K8x8QGQMVMKm7ZmCD//bu VXry0a3uskX/IiiZc4QCb+Q7QJjSLeuYG+Jg4qweMoP3a9qRT9jQJXJjoSUi/5MHikYB Hg1w== X-Gm-Message-State: AG10YOSiHDtH8am7J4+akVAPdH9Kg2LUOsQ87192uKUcR32W3lMRRJnIxAjMyXhhhHZKyJpJP3OAcak8HdEBLQ== X-Received: by 10.107.132.90 with SMTP id g87mr7736969iod.157.1455793625234; Thu, 18 Feb 2016 03:07:05 -0800 (PST) In-Reply-To: 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:103106 On Thu, Feb 18, 2016 at 9:57 PM, Cem Karan wrote: > I agree with Chris on all his points. My personal feeling is that Py3 is= the way to go for teaching in the future; its just that little bit more co= nsistent across the board. And the things that are confusing are not thing= s that beginners will need to know about. > > About the only thing I've read where Py2 has a slight advantage is for sc= ripts where you're suddenly surprised by Py2 starting up when you've been u= sing a Py3 interactive interpreter. For me, I'd probably give my students = a block of code that they are asked to copy at the start of their files to = test for Py2 or Py3, and to raise an exception on Py2. After that, I just = wouldn't worry about it. > Another solution is to have a little bit of boilerplate at the shell first: python3 -m venv env source env/bin/activate Then both "python" and "python3" will run the binary from your virtual environment, and as a side bonus, you get to use pip without root privileges. By the way... For bash users, adding this to .bashrc may make venvs a bit easier to keep straight: checkdir() { [ -n "$VIRTUAL_ENV" ] && ! [[ `pwd` =3D~ `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=3Dcheckdir (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.) ChrisA