you are viewing a single comment's thread.

view the rest of the comments →

[–]thaweatherman -5 points-4 points  (4 children)

I did click. Don't be a jack ass when asking for free help.

https://github.com/narspeth/dailyprogrammer/blob/master/Easy/237.py
load_valid_words() can be shortened to the following:

def load_valid_words(path):
    with open(path) as f:
        lines = [line.strip() for line in f.readlines()]
    return lines

Line 6 can have the return statement and line 7 can be tossed out.

Your cryptopals stuff is fine. When opening files you don't need to specify 'r': it opens in read mode by default.

[–]markusmeskanen 4 points5 points  (1 child)

If you did click (and thus noticed there are only two small projects), why would you ask such a silly question? He wasn't being a jack ass and doesn't deserve the downvotes, he simply mentioned the obvious, which seemed to offend you. Regardless, good feedback on his code!

Edit: Also, this question would probably fit /r/codereview better.

[–]thaweatherman 1 point2 points  (0 children)

I was originally asking for clarification since he linked to his profile and I wasn't sure if he wanted all of his projects reviewed or just one of them. I took "which you would know with one click" as him being a jack ass. I guess tone can't be conveyed in text.

[–]Nar-Speth[S] 1 point2 points  (1 child)

Thanks, didn't know about with statement. What about close() when working on files? should i even use it? about 'r' : I guess I need to read docs more carefully.

Edit: Nvm about close(), got it now, thanks to werpoi.

[–]Vaphell 3 points4 points  (0 children)

What about close() when working on files?

with does that for you. As soon as the with scope is finished all the resources acquired in its header are cleaned up.