Wednesday, September 16, 2009

Add color to your html posted python code


# create color coated python code (so you can
#   post more readable code online!)
# get the recipe from http://code.activestate.com/recipes/52298/

# this is mostly borrowed from the recipe
# I saved the recipe as pycolor.py
# 
import pycolor

print "Formatting..."

# open you file's source
source = open('colormaker.py').read()

# write colorized version to ".html"
pycolor.Parser(source, open('colormaker.html', 'wt')).format(None, None)

No comments:

Post a Comment