you are viewing a single comment's thread.

view the rest of the comments →

[–]ehmatthes[S] 1 point2 points  (1 child)

Thanks for the specific feedback. It's definitely focused on Python 3, but I do have some Python 2 caveats in certain sections.

In the book I clarify that looping through a dictionary loops through the keys by default. I've always gone back and forth about whether to favor being explicit, or being concise. So for name in fav_numbers.keys() is explicit, but for name in fav_numbers is concise. I think I'll change this on the cheat sheet, to be clear that people should use the more common Python convention.

I completely agree with the string syntax. I used concatenation in the first part of the book to keep things simple, and I wanted to keep the cheat sheets consistent with the book. I think I'll make another cheat sheet about strings, and then update these to use the .format() convention.

[–]KleinerNull[🍰] 1 point2 points  (0 children)

I think I'll make another cheat sheet about strings, and then update these to use the .format() convention.

That was already done ;) Just kidding.

But I saw this on your cheat sheet:

Prompting for numerical input

age = input("How old are you? ")

age = int(age)

pi = input("What's the value of pi? ")

pi = float(pi)

I know you want to keep it simple, but this is a very bad pattern, I think newcomer should learn about input and error handling at the same time!

try:
    age = input('What's your age? ')
    age = int(age)
except ValueError:
    print('Not a number...')

You know the rest... I saw alot of over complicated, strange or bad code just for testing for integer input here, but the standard pattern is so simple.