Learn Python from scratch: Part 3. What is ‘#’ and its use in Python?

It was a beautiful weekend in Sydney, if you are living in another part of the world and you do not like the hot and sticky summer, (although we are known for a beautiful hot and dry summer in OZ), for many, the best time to visit Sydney is in the Australian spring. (September 1 to November 30). OK, enough about the whether, let’s jump straight into today’s topic.


The symbol ‘#’ is called by many different names: hash; pound (don’t confuse with British pound); sharp (as in number 1 = #1); octothorpe (named as it has 8 points); a square (on Telephone pad) and more recently used in social media as hashtag something. I will go with the name hash as it is a laymen’s term and I will always choose practicality over elegance.  I will leave the picturesque name ‘octothorpe’ for someone who likes to show off their linguistic vocabulary superiority, sticking their nose high in the air every time they say the word ‘octothorpe’, I am a practical guy, so we’ll go with the term ‘hash’.


Use in programming, # is used to disable parts of your program or leave an instructional comments for the next programming users. Also on some occasions, # has some other special function as in an example of “# -*- coding: utf-8 -*-“.


Task: Copy and paste the following or write something up yourself. Save the file as script2.py and save it to your desktop. Run the script2.py in your Terminal.

# Script2.py is a lesson on # and its use. # has many names, call me as you like in your country.

# Look at the use of me in the following example.

print “I like my #brown in the morning.”

print “I also like my sunny side-up fried egg as part of my breakfast”

# print “You want see this line as I commented this line out with a #.!”


Linux session – run script2.py file in CLI terminal as shown below:

script2- linux


Windows session – run script2.py file in PowerShell terminal as shown below: script2- windows

I could find the use of # in SecureCRT initialization file and also in Dynamips/GNS3 .net files. Look around and find out some of your examples of # use in your own testing environment. For now, hashtag out…

Leave a comment