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:

  1. having comments before commented item python users expect majority of is "more readable"

  2. 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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -