-
-
Notifications
You must be signed in to change notification settings - Fork 807
Minor updates for Python 3 compatibility #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Mostly these are just noticing when Python 3 gives different outputs than Python 2 and updating accordingly, and a few spots where print statements were missed (I think these print statements were added after the PR was made). One odd thing is that in Python 3, the list returned by `glob` isn't sorted. I'm not sure if this is also true in Python 2, but to be sure that the output is correct, I added `sorted` calls. Another somewhat large change is that the exception classes are changed in Python 3; importantly, there's no longer a base IOError. Instead, the specific IOErrors are separated out. Updated that lesson accordingly. Things I noticed but didn't change: 1. I found many floats that truncated differently in the lessons (e.g., 126.5) that truncated differently in my Python 3 environment (e.g., 126.50000000000001). This might be something specific to my machine though, not necessarily Python 3? 2. In 02-loop, the challenge "From 1 to N" mentions that range(3) produces [0, 1, 2]. In Python 3 it instead produces an object, which prints as range(0, 3). You can still iterate over it though, so it doesn't directly affect the challenge, but the pedant in me has a "well, actually" moment when I read the challenge. 3. In Lesson 6, the difference in standard deviations before and after is exactly zero on my machine. I'm not sure if this is, again, a machine difference, or if it's a Python 3 difference.
|
@tbekolay Thanks for the pull request. Looks great to me.
That is true. At the begin Python only had lists so If I made a mistake, please correct me. =) |
Right yeah. Do you think it makes sense to include the |
My first thought is yes but I agree with you when you say
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please modify to show glob.glob first (with items not sorted), then introduce sorted in a callout box with a note saying "you should only bother to sort if you really care, and you usually only really care as the last step of processing".
Minor updates for Python 3 compatibility
Minor updates for Python 3 compatibility
Note that this is a PR on the
py3kbranch.I did a runthrough of the Python 3 lessons after merging @rgaiacs's PR to clean up any loose ends. After making these changes, the lesson runs properly for me in Python 3.
Often, these changes are just noticing when Python 3 gives different outputs than Python 2 and updating accordingly, and a few spots where we still had print statement (these were added after #142 was made).
One odd thing is that in Python 3, the list returned by
globisn't sorted. I'm not sure if this is also true in Python 2, but to be sure that the output is correct, I addedsortedcalls.Another somewhat large change is that the exception classes are changed in Python 3; importantly, there's no longer a base IOError. Instead, the specific IOErrors are separated out. Updated that lesson accordingly.
Things I noticed but didn't change: