Mike's Memoirs - The love of coffee, condiments and code.

Posts Tagged ‘programming’

Code

Fri, 18th Sep, 2009

Toggling code blocks in Python

Tags: , , ,

I have found a pretty simple method of toggling large blocks of code in Python.

Basically this:

#Add/remove below hash to toggle code blocks.
#"""
print "Code block one!"
"""
print "Code block number 2."
"""
#"""

Note: This is not highlighted correctly because of a limitation of the highlighter I use :(

In this default state (with the initial #) the first block of text is active with the second commented out. Removing this hash will invent the code commenting.

I’ve been doing this in PHP for years, but only recently figured it out in Python!