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

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!

  1. Have you written any Python astro code for your DSLR workflow?

    Comment by Ray — Mon, 14th Dec, 2009 @ 5:30am
  2. I’m not sure what you mean, could you explain more?

    Comment by Mike — Mon, 14th Dec, 2009 @ 8:13am

Leave a comment

RSS feed for comments on this post. TrackBack URL