Robin Andrews
Robin Andrews

Reputation: 3804

Section Header Comments in Python

I've searched on Google and could not find any information on recommended ways to highlight sections of code with comments.

I'm thinking of something like this:

###########################################################
# This section is clearly labeled using comments so you can 
# instantly identify its purpose within this file.
###########################################################

I see this kind of thing a lot in php for example.

Is there a convention for this kind of thing in python? If not, is there a good reason to avoid it?

If this is generally done using multi-line comments, could someone please provide an example of how it's done in this "headline" style?

EDIT: I know about multi-line comments. But generally I associate these with a single function rather than a section of code. So more specifically I'm thinking something like this for a small game in a single file:

###################################################
#              CONFIGURATION   
##################################################

configuration code...

###################################################
#              HELPER FUNCTIONS
#################################################   

helper functions.....

###################################################
#                 GRAPHICS HANDLING
#######################################################

graphics handling....

Upvotes: 8

Views: 5961

Answers (1)

Robin Andrews
Robin Andrews

Reputation: 3804

##############
# Game Setup #
##############

code...

##################
# Function Setup #
##################

code...

################
# Screen Setup #
################

code...

That's the kind of thing I meant. Found some good examples in https://github.com/lordmauve/pgzero

Upvotes: 3

Related Questions