Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98029 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2015-11-01 20:43 +1100 |
| Last post | 2015-11-03 01:10 +1100 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
Python 2 vs Python 3 for teaching Chris Angelico <rosuav@gmail.com> - 2015-11-01 20:43 +1100
Re: Python 2 vs Python 3 for teaching beliavsky@aol.com - 2015-11-02 05:15 -0800
Re: Python 2 vs Python 3 for teaching Chris Angelico <rosuav@gmail.com> - 2015-11-03 01:10 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-11-01 20:43 +1100 |
| Subject | Python 2 vs Python 3 for teaching |
| Message-ID | <mailman.7.1446371003.4463.python-list@python.org> |
I'm proud to say that a Python tutoring company has just converted its
course over from teaching Python 2.7 to teaching 3.x. For the
naysayers out there, it actually wasn't much of a transition; putting
parentheses around all print calls, plus changing the way virtual
environments get created, pretty much covered it. The difference
between well-written 2.7 code and well-written 3.4 code is really not
huge.
Interestingly, the bytes/unicode distinction wasn't much of an issue.
Under 2.7, a lot of functions return Unicode strings, and their reprs
show a u prefix, which disappears under Py3. In both cases, a Unicode
string returned from a library will compare equal to a simple
double-quoted string:
>>> import json
>>> json.loads('["Hello", "World"]')
[u'Hello', u'World']
>>> _[0] == "Hello"
True
The bulk of the changes were actually just changing displayed output
to match a change to some object's repr (eg "<type 'bool'>" becomes
"<class 'bool'>", and "set([1])" becomes "{1}"), or the exact text of
an exception (the TypeError from evaluating None[0] looks different,
but it's still a TypeError).
Who out there is currently teaching/tutoring/training using Python 2?
Push to the common subset (parenthesized single string prints, never
assuming int/int yields int, etc), with a view to migration - it's
easier than you might think!
(This isn't meant to be an ad for a specific company, so much as a
general recommendation to push to Py3, but they deserve a bit of a
shout-out anyway. The company is Thinkful, www.thinkful.com.)
ChrisA
[toc] | [next] | [standalone]
| From | beliavsky@aol.com |
|---|---|
| Date | 2015-11-02 05:15 -0800 |
| Message-ID | <c6405c34-43cc-417b-9027-12e3ac1bbfb5@googlegroups.com> |
| In reply to | #98029 |
I think Python 2.x is still used more than Python 3.x in scientific computing. The Python books I have in this area, such as "Python for Finance: Analyze Big Financial Data" and "Python for Data Analysis", still use Python 2.x . An aspiring computational scientist, data scientist, or financial quant may still be better off learning Python 2.x but using print(x) rather than print x and doing other things to future-proof his code.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-11-03 01:10 +1100 |
| Message-ID | <mailman.63.1446473422.4463.python-list@python.org> |
| In reply to | #98096 |
On Tue, Nov 3, 2015 at 12:15 AM, beliavsky--- via Python-list <python-list@python.org> wrote: > I think Python 2.x is still used more than Python 3.x in scientific computing. The Python books I have in this area, such as "Python for Finance: Analyze Big Financial Data" and "Python for Data Analysis", still use Python 2.x . An aspiring computational scientist, data scientist, or financial quant may still be better off learning Python 2.x but using print(x) rather than print x and doing other things to future-proof his code. > That doesn't mean that Python 3 *can't* be used. Far as I know, all the key libraries (numpy, pandas, statsmodels, scipy) are available for Python 3 as well. Recommending the use of Python 2 simply because all the books you have teach Python 2 is a purely circular argument. But yes. If you're going to use Py2, aim for the common subset. Good Py2 code is a lot more similar to good Py3 code than an enumeration of language-level differences would suggest. ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web