News for hackers. Stuff that matters.
Re:Key differences between Python 2.7.x and Python 3.x (2014) by narimiran on Sunday May 07, 2017 @04:00PM (#14287290)
> In Python 3, I have to tell my students that

> breakfast = ["bacon", "eggs"]

> sorted_breakfast = breakfast.sort()

> works

Well, some of your students might point out to you that your `sorted_breakfast` is `None`, because that is what `sort()` returns, and even this example doesn't work as you have wanted ;)

On the other hand, if you have used `sorted(breakfast)` (and `sorted(breakfast.keys())` in other example), both examples would work as intended, and you couldn't blame Python 3.

> "Why is sorted() rather than sort()" - "just because."

It is not "just because", it is because it returns a sorted list (which is exactly what you wanted), compared to returning None.

Re:Key differences between Python 2.7.x and Python 3.x (2014) by masklinn on Sunday May 07, 2017 @05:33PM (#14287808)
> It is not "just because", it is because it returns a sorted list (which is exactly what you wanted), compared to returning None.

Also because `sorted()` works on any iterable, whereas .sort only works on lists.

Re:Key differences between Python 2.7.x and Python 3.x (2014) by xapata on Monday May 08, 2017 @01:28AM (#14289441)
I know that the best way to learn is "see one, do one, teach one" but I wish you'd put more effort into learning the language before teaching it.

The python.org tutorial and FAQ have answers to these questions.

I think it's unethical to tell a student, "just because" instead of, "I don't know why."

Re:Key differences between Python 2.7.x and Python 3.x (2014) by narimiran on Monday May 08, 2017 @02:07AM (#14289580)
You're replying to the wrong person. I'm not the one who is doing teaching, I'm just the guy who corrects the teacher who hates Python 3 (for wrong reasons) ;)
Re:Key differences between Python 2.7.x and Python 3.x (2014) by xapata on Monday May 08, 2017 @11:02AM (#14292080)
Sorry about that.