Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103106
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Guido on python3 for beginners |
| Date | 2016-02-18 22:07 +1100 |
| Message-ID | <mailman.245.1455793627.22075.python-list@python.org> (permalink) |
| References | (7 earlier) <56c568f2$0$2832$c3e8da3$76491128@news.astraweb.com> <CAPTjJmrF2=V0s=g5OzepLozhyS7KToqUiKK3A4FjzbnwuCwsnw@mail.gmail.com> <na4018$un9$1@ger.gmane.org> <CAPTjJmp_MxJLpuRt3VRtT7E3pV2Brty_U5PaXEJ4h6bnY6bS4A@mail.gmail.com> <CA790464-2C9C-4BFE-9BAC-64CBDE4799DB@gmail.com> |
On Thu, Feb 18, 2016 at 9:57 PM, Cem Karan <cfkaran2@gmail.com> 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 consistent across the board. And the things that are confusing are not things that beginners will need to know about.
>
> About the only thing I've read where Py2 has a slight advantage is for scripts where you're suddenly surprised by Py2 starting up when you've been using 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` =~ `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.)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Rick Johnson <rantingrickjohnson@gmail.com> - 2016-02-02 19:26 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO John Ladasky <john_ladasky@sbcglobal.net> - 2016-02-02 22:02 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-03 04:07 -0200
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Rick Johnson <rantingrickjohnson@gmail.com> - 2016-02-06 12:54 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO INADA Naoki <songofacandy@gmail.com> - 2016-02-07 12:02 +0900
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-02-07 16:59 +1100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Paul Rubin <no.email@nospam.invalid> - 2016-02-06 23:04 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Rustom Mody <rustompmody@gmail.com> - 2016-02-06 23:31 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Paul Rubin <no.email@nospam.invalid> - 2016-02-06 23:51 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Chris Angelico <rosuav@gmail.com> - 2016-02-07 18:58 +1100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Jason Swails <jason.swails@gmail.com> - 2016-02-08 10:20 -0500
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Christian Gollwitzer <auriocus@gmx.de> - 2016-02-07 08:44 +0100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Chris Angelico <rosuav@gmail.com> - 2016-02-07 14:06 +1100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-08 08:40 -0700
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Random832 <random832@fastmail.com> - 2016-02-08 10:44 -0500
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO wxjmfauth@gmail.com - 2016-02-09 01:15 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Chris Angelico <rosuav@gmail.com> - 2016-02-09 02:46 +1100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Random832 <random832@fastmail.com> - 2016-02-08 10:53 -0500
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Chris Warrick <kwpolska@gmail.com> - 2016-02-08 18:48 +0100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO John Ladasky <john_ladasky@sbcglobal.net> - 2016-02-11 23:51 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Rick Johnson <rantingrickjohnson@gmail.com> - 2016-02-15 18:02 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Chris Angelico <rosuav@gmail.com> - 2016-02-16 13:30 +1100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO John Ladasky <john_ladasky@sbcglobal.net> - 2016-02-15 21:24 -0800
Guido on python3 for beginners Rustom Mody <rustompmody@gmail.com> - 2016-02-17 00:51 -0800
Re: Guido on python3 for beginners Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-02-18 17:47 +1100
Re: Guido on python3 for beginners Ben Finney <ben+python@benfinney.id.au> - 2016-02-18 17:57 +1100
Re: Guido on python3 for beginners Paul Rubin <no.email@nospam.invalid> - 2016-02-17 22:59 -0800
Re: Guido on python3 for beginners "Sven R. Kunze" <srkunze@mail.de> - 2016-02-18 22:37 +0100
Re: Guido on python3 for beginners Random832 <random832@fastmail.com> - 2016-02-18 02:00 -0500
Re: Guido on python3 for beginners Chris Angelico <rosuav@gmail.com> - 2016-02-18 18:27 +1100
Re: Guido on python3 for beginners John Ladasky <john_ladasky@sbcglobal.net> - 2016-02-18 12:22 -0800
Re: Guido on python3 for beginners INADA Naoki <songofacandy@gmail.com> - 2016-02-18 17:00 +0900
Re: Guido on python3 for beginners Terry Reedy <tjreedy@udel.edu> - 2016-02-18 03:40 -0500
Re: Guido on python3 for beginners Steven D'Aprano <steve@pearwood.info> - 2016-02-20 18:59 +1100
Re: Guido on python3 for beginners Chris Angelico <rosuav@gmail.com> - 2016-02-18 20:57 +1100
Re: Guido on python3 for beginners Cem Karan <cfkaran2@gmail.com> - 2016-02-18 05:57 -0500
Re: Guido on python3 for beginners Chris Angelico <rosuav@gmail.com> - 2016-02-18 22:07 +1100
Re: Guido on python3 for beginners Rustom Mody <rustompmody@gmail.com> - 2016-02-18 04:25 -0800
Re: Guido on python3 for beginners Random832 <random832@fastmail.com> - 2016-02-18 10:51 -0500
Re: Guido on python3 for beginners Steven D'Aprano <steve@pearwood.info> - 2016-02-19 12:17 +1100
Re: Guido on python3 for beginners Rustom Mody <rustompmody@gmail.com> - 2016-02-18 19:39 -0800
Re: Guido on python3 for beginners Steven D'Aprano <steve@pearwood.info> - 2016-02-20 13:36 +1100
Re: Guido on python3 for beginners Larry Hudson <orgnut@yahoo.com> - 2016-02-20 00:37 -0800
Re: Guido on python3 for beginners Grant Edwards <invalid@invalid.invalid> - 2016-02-19 15:06 +0000
Re: Guido on python3 for beginners Rustom Mody <rustompmody@gmail.com> - 2016-02-18 19:32 -0800
Re: Guido on python3 for beginners Matt Wheeler <m@funkyhat.org> - 2016-02-18 16:44 +0000
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO wxjmfauth@gmail.com - 2016-02-17 08:39 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Christian Gollwitzer <auriocus@gmx.de> - 2016-02-18 22:14 +0100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Chris Angelico <rosuav@gmail.com> - 2016-02-19 08:54 +1100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-18 21:07 -0700
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO wxjmfauth@gmail.com - 2016-02-19 02:18 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2016-02-03 09:27 +0100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Grobu <snailcoder@retrosite.invalid> - 2016-02-03 09:38 +0100
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO wxjmfauth@gmail.com - 2016-02-03 09:16 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Quivis <quivis@domain.invalid> - 2016-02-06 14:59 +0000
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Ethan Furman <ethan@stoneleaf.us> - 2016-02-18 18:22 -0800
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-02-19 10:05 +0000
Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO Terry Reedy <tjreedy@udel.edu> - 2016-02-19 23:15 -0500
csiph-web