realpython / python-guide

Python best practices guidebook, written for humans.
https://docs.python-guide.org
Other
28.17k stars 5.82k forks source link

Python 2 syntax in examples, why? #1091

Closed matheusfelipeog closed 3 years ago

matheusfelipeog commented 3 years ago

Hi :)

Why use python 2 syntax in examples today? Since Python 2 has been discontinued in January 1, 2020.

Examples:

four_lists = [[] for __ in xrange(4)]

instead:

four_lists = [[] for __ in range(4)]

Has a note stating the new syntax:

Note: Use range() instead of xrange() in Python 3.

But is this really necessary today? Isn't it better to update everything to Python 3 syntax?

matheusfelipeog commented 3 years ago

If allowed, I can update everything to Python 3 syntax ;)

dbader commented 3 years ago

@matheusfelipeog Agreed, I think it's time to switch the Guide over to Python 3 🙂

If allowed, I can update everything to Python 3 syntax ;)

Well, that'd be amazing. If you want to put together a pull-request (or a series of PRs we can merge one by one) to make some of these updates that'd be great.

matheusfelipeog commented 3 years ago

Right 😆

I will start the update soon.

matheusfelipeog commented 3 years ago

I updated everything I found 😄

I made a pull request per updated section

dbader commented 3 years ago

Cheers @matheusfelipeog, I just merged those PRs :) Nice work.