Live data from Hacker News

Python Practice Book

anandology.com

31–37 of 37 posts

Re: Python Practice Book

#31
post #28
post #3

FYI: It's Python 2, teaching Python 2 syntax. Given the state of the whole 2 vs. 3 debate, I'm always surprised that libaries and books don't post their requirements or used versions more prominently.

Most of the writing are Python 2 and 3 compatible (sure the print statement is enough to throw Python 3 off) and this was written back in 2012 when Python 2 was still the center of the community. Maybe the author thinks writing down the interpreter (Python 2.7.1) on the first chapter is good enough. Also, this was prepared for a training if you read the side. So students who took the author's training probably knew i…

Actually, leaving out `object` is the preferred convention for Python 3, as they are semantically equivalent. In Python 2, they mean different things, and you generally want to mean `class Name(object):`. Explicit is better than implicit.

Re: Python Practice Book

#32
post #28
post #3

FYI: It's Python 2, teaching Python 2 syntax. Given the state of the whole 2 vs. 3 debate, I'm always surprised that libaries and books don't post their requirements or used versions more prominently.

Most of the writing are Python 2 and 3 compatible (sure the print statement is enough to throw Python 3 off) and this was written back in 2012 when Python 2 was still the center of the community. Maybe the author thinks writing down the interpreter (Python 2.7.1) on the first chapter is good enough. Also, this was prepared for a training if you read the side. So students who took the author's training probably knew i…

If you have Python 2.7.5, then print('hello') just works for you.

Re: Python Practice Book

#33
post #8

hmm Python2 - http://pymbook.readthedocs.org/en/latest/ Python3 - http://pymbook.readthedocs.org/en/py3/

Looks like this has been fixed now; latest takes you to the Python 3 page. ...and py3 takes you to the python 2 page O_o

py3 branch is the Python 3 version, which is a ongoing work.

Re: Python Practice Book

#34
post #28

Earlier quoted context omitted.

Most of the writing are Python 2 and 3 compatible (sure the print statement is enough to throw Python 3 off) and this was written back in 2012 when Python 2 was still the center of the community. Maybe the author thinks writing down the interpreter (Python 2.7.1) on the first chapter is good enough. Also, this was prepared for a training if you read the side. So students who took the author's training probably knew i…

Actually, leaving out `object` is the preferred convention for Python 3, as they are semantically equivalent. In Python 2, they mean different things, and you generally want to mean `class Name(object):`. Explicit is better than implicit.

Why is this a 'preferred convention' for Python3? Doing this causes a lot of confusion for Python beginners that write code in Python2 (i.e. it causes them to accidentally use old-style classes). A better practice is to add the extra word i.e. 'class ClassName(object):' for both Python2 and Python3 code. This is especially true if you are writing Python tutorials. Since we are going through this Python2 to Python3 transition it is better to minimize the differences in the cases where they don't really matter (i.e. add the extra 'object' word).

Re: Python Practice Book

#35
post #34

Earlier quoted context omitted.

Actually, leaving out `object` is the preferred convention for Python 3, as they are semantically equivalent. In Python 2, they mean different things, and you generally want to mean `class Name(object):`. Explicit is better than implicit.

Why is this a 'preferred convention' for Python3? Doing this causes a lot of confusion for Python beginners that write code in Python2 (i.e. it causes them to accidentally use old-style classes). A better practice is to add the extra word i.e. 'class ClassName(object):' for both Python2 and Python3 code. This is especially true if you are writing Python tutorials. Since we are going through this Python2 to Python3 tr…

It's considered a wart that old style classes even exist in the first place. Classes look way nicer without it.

Imagine having to write `extends Object` for every Java class you make.

Re: Python Practice Book

#36
post #3

FYI: It's Python 2, teaching Python 2 syntax. Given the state of the whole 2 vs. 3 debate, I'm always surprised that libaries and books don't post their requirements or used versions more prominently.

Thanks for the suggestion. Added a note on the index page.
Post reply on HN