Love to get some feedback on my first python app!!!

Chris Angelico rosuav at gmail.com
Mon Sep 22 08:23:00 EDT 2014


On Mon, Sep 22, 2014 at 10:00 PM,  <vek.m1234 at gmail.com> wrote:
> https://github.com/Veek/Python/blob/master/IRC/Hexchat/fake_ctcp.py
> that's not too bad as far as readability is concerned and it's bereft of all comments {:p

Sure, I can work out what it's doing without comments. Doesn't mean
comments are bad, though. Also, without comments, I have no idea *why*
it's doing what it does. For instance, this:

> def debug(msg):
>     hexchat.prnt('{}'.format(msg))

Why not just do this:
debug = hexchat.prnt

Or, better still, just use hexchat.prnt() everywhere, instead of
having a local name? (You happily use hexchat.* in other places.) Is
it meant to be monkey-patched externally? Is it meant to be a
one-place edit? What's the purpose of this one-line function?

> date = str(date_s) + ' ' + str(hour) + ':' + str(min) + ':' + str(sec)

You use .format() in places where it's completely unnecessary, but
eschew it when it would make your code more readable.

date = "%s %s:%s:%s" % (date_s, hour, min, sec)
date = "{} {}:{}:{}".format(date_s, hour, min, sec)

So, comments would definitely help. In some cases, would help a lot.

ChrisA



More information about the Python-list mailing list