SOBotics / notepad

Small notepad bot for the room
0 stars 3 forks source link

Style stuff #2

Open adeak opened 6 years ago

adeak commented 6 years ago

A bunch of minor mostly-style changes organized in several commits for ease of cherry-picking.

  1. Use a triple-quoted string for the help message. On the one hand this should be more idiomatic, on the other hand this needs a combination of textwrap.dedent and .indent to keep it pretty, and the latter is missing in python 2. Also, the change adds a newline at the end of the help string, but the chat engine should ignore that.
  2. Use format strings where possible (TODO: f-strings once 3.6 is the new norm ;)
  3. Use context managers for the data files.
  4. Add explicit elifs to chained mutually exclusive ifs. Some of these are extra redundant because there are return statements interspersed, it's a matter of personal taste whether explicit elifs aid readability.
  5. Use advanced iterable unpacking to make head|rest and garbage|tail kind of list separations a bit more convenient.