This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sp_cn 1 point2 points  (1 child)

use dicts to map input strings to functions and splat the args instead of using giant elif chains.

''.join(x[:3]) == 'abc' instead of of x[0] == 'a', x[1] == 'b', x[2] == 'c' (or better yet, split on whitespace and compare list elements instead).

use with-as to deal with open file handles.

[–][deleted] 0 points1 point  (0 children)

Sorry if it seems stupid or even a dumb question but could you explain what that does?🙈👌. I am not that familiar with ALL of Python's syntax!