pep - python multiline comment indent -
i have django project, , in places have multiline comments indented follows:
field = models.integerfield(default=0, null=true) # 0-initial_email_sent # 1-second_email_sent # 2-third_email_sent
this violates pep, but, in opinion, helps readability. of course, put comments this:
# 0-initial_email_sent # 1-second_email_sent # 2-third_email_sent field = models.integerfield(default=0, null=true)
, rather prefer first one.
is there way indent comments such without violating pep?
magic numbers evil, best documentation here use named (pseudo) constants:
initial_email_sent = 0 second_email_sent = 1 third_email_sent = 2 field = models.integerfield(default=initial_email_sent, null=true)
as general rule, less have comment better (clear code needs no or very few comments).
for more general answer place comments, specially multiline ones:
having comments before commented item python users expect majority of is "more readable"
it makes code editing easier (you don't have comments mixed code, don't have maintain comments indentation etc).
if it's own personal project , don't plan on sharing or having else working on (hopefully) free use coding style / convention, pep08 no religion, if else ever have work on code hate commenting way.
Comments
Post a Comment