Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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....
like image 685
Robin Andrews Avatar asked Jul 02 '26 18:07

Robin Andrews


1 Answers

##############
# 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

like image 190
Robin Andrews Avatar answered Jul 04 '26 08:07

Robin Andrews



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!